@lumen-stack/react 0.13.0 → 0.14.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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import*as _n from'react';import {createContext,useRef,useState,useCallback,useEffect,useImperativeHandle,useContext,useMemo,useId}from'react';import {toast,Toaster}from'sonner';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var O=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},on=class extends O{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},an=class extends O{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},pt=class extends O{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},Vr="https://shakebugs.vercel.app",zr="/api/v1/sdk/submit",$r="/api/v1/sdk/error",Wr="0.13.2",Kr=5,qr=new Set([502,503,504]),gn=class{apiKey;apiUrl;user;amplitude;#e=new Set;#t=0;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new O("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??Vr).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${zr}`,r=this.#n(e),o=null;for(let a=0;a<3;a++){a>0&&await Yr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof on||i instanceof an||i instanceof O&&typeof i.status=="number"&&!qr.has(i.status))throw i}}throw o instanceof Error?o:new pt("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Kr)return;let t=(e.stack??"").split(`
3
3
  `)[1]?.trim()??"",n=`${e.name}:${e.message}@${t}`;if(this.#e.has(n))return;this.#e.add(n),this.#t+=1;let r=typeof navigator<"u"?navigator:void 0,o=typeof performance<"u"?performance.memory:void 0,a;try{let u=new URL(window.location.href);a=u.origin+u.pathname;}catch{a=void 0;}let i={message:String(e.message??"").slice(0,1e3),name:String(e.name??"Error").slice(0,200),stack:e.stack?.slice(0,8e3),componentStack:e.componentStack?.slice(0,8e3),url:a,userAgent:r?.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},dpr:window.devicePixelRatio,deviceMemory:r?.deviceMemory,jsHeap:o?{used:o.usedJSHeapSize,limit:o.jsHeapSizeLimit}:void 0,sdkVersion:Wr,context:e.context};fetch(`${this.apiUrl}${$r}`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumen-Api-Key":this.apiKey},body:JSON.stringify(i),keepalive:!0,credentials:"omit",mode:"cors"}).catch(()=>{});}catch{}}#n(e){let t=new FormData;e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),e.priority&&t.append("priority",e.priority),e.source&&t.append("source",e.source),e.submitterEmail&&t.append("submitterEmail",e.submitterEmail),e.submitterFingerprint&&t.append("submitterFingerprint",e.submitterFingerprint);let n=e.context.amplitude??this.amplitude,r=n?{...e.context,amplitude:n}:e.context;return t.append("context",JSON.stringify(r)),e.screenshot&&t.append("screenshot",e.screenshot,jr(e.screenshot)),e.audio&&t.append("audio",e.audio,"audio"),e.audioDurationMs!=null&&t.append("audioDurationMs",String(e.audioDurationMs)),e.video&&t.append("video",e.video,"video"),e.videoDurationMs!=null&&t.append("videoDurationMs",String(e.videoDurationMs)),t}#r(e,t,n){return new Promise((r,o)=>{let a=new XMLHttpRequest;a.open("POST",e,true),a.setRequestHeader("X-Lumen-Api-Key",this.apiKey),a.responseType="text";let{onUploadProgress:i,signal:u}=n;i&&a.upload.addEventListener("progress",c=>{c.lengthComputable&&c.total>0&&i(Math.min(1,c.loaded/c.total));});let d=()=>{a.abort(),o(new pt("Submit aborted."));};if(u){if(u.aborted){o(new pt("Submit aborted."));return}u.addEventListener("abort",d,{once:true});}a.addEventListener("load",()=>{if(u&&u.removeEventListener("abort",d),a.status===403){o(new on);return}if(a.status===429){let c=Number(a.getResponseHeader("Retry-After"))||60;o(new an(c));return}if(a.status<200||a.status>=300){o(new O(Gr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let c=JSON.parse(a.responseText);r(c);}catch{o(new O("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{u&&u.removeEventListener("abort",d),o(new pt("Network error during submit."));}),a.send(t);})}};function jr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Yr(e){return new Promise(t=>setTimeout(t,e))}function Gr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var vn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function wn(e=vn){if(!e||typeof document>"u")return ()=>{};let t=[];for(let n of Array.from(document.querySelectorAll(e)))t.push({el:n,prev:n.style.visibility}),n.style.visibility="hidden";return ()=>{for(let{el:n,prev:r}of t)n.style.visibility=r;}}var Zr=2,Xr=1.5,Jr=820,Qr=12,Je=8*1024*1024;async function bt(e={}){At();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return io(await e.provider(),e)}catch(n){if(t==="custom")throw n;e.onWarning?.(["Custom capture provider failed; falling back to browser DOM capture."]);}if(t==="manual")throw new O("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return cn(e);if(t==="dom")return ln(e);if(t==="custom")throw new O("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await ln(e)}catch(n){if(kn()){let r=await cn(e);return r.warnings=et(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function Qe(e,t=[]){At();let n=gt();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:et(t)}}var sn=Promise.resolve();function ln(e){let t=sn.then(()=>un(e),()=>un(e));return sn=t.catch(()=>{}),t}async function un(e){let t=await ao(),n=e.target??document.documentElement,r=gt(),o=lo(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),u=window.scrollY+(a?.offsetTop??0),d=uo(e,r.width,r.height),c=so(n);!e.provider&&oo()&&c.unshift(`Lumen is capturing inside a React Native WebView with no native capture provider, so this screenshot is a DOM re-render \u2014 it won't match the native screen and omits native overlays/inputs. Wire createNativeCaptureProvider() with capture mode "custom" (see docs/native-screenshot-expo.md).`);let m=no(n);await Rn(e.awaitAnimationsMs??po),await mo();let p=await t(n,{backgroundColor:null,logging:false,useCORS:true,allowTaint:false,width:r.width,height:r.height,windowWidth:o.width,windowHeight:o.height,scrollX:window.scrollX,scrollY:window.scrollY,x:i,y:u,scale:d,ignoreElements:v=>v instanceof HTMLElement&&(v.dataset.lumenCaptureIgnore==="true"||!!v.closest("[data-lumen-capture-ignore='true']")),onclone:(v,y)=>{ro(y,m),eo(v);}}),C={blob:await Cn(p,c),method:"web-dom",platform:"web",viewport:r,pixelRatio:d,warnings:et(c)};return C.warnings.length>0&&e.onWarning?.(C.warnings),C}var yn=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function eo(e){for(let t of Array.from(e.querySelectorAll(yn))){if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){let n=t;n.value&&(n.value="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");continue}t.style.visibility="hidden";}}var to="[data-lumen-root], [data-lumen-capture-ignore='true']";function En(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(to))}function no(e){return En(e).map(t=>{if(t.matches(yn))return {skip:true};let n=t.type;return n==="checkbox"||n==="radio"?{skip:false,checked:t.checked}:n==="file"?{skip:true}:{skip:false,value:t.value}})}function ro(e,t){let n=En(e);n.length===t.length&&n.forEach((r,o)=>{let a=t[o];!a||a.skip||(a.checked!==void 0?r.checked=a.checked:a.value!==void 0&&(r.value=a.value));});}function oo(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function ao(){let{default:e}=await import('html2canvas-pro');return e}async function Nt(e={}){if(At(),!kn())throw new O("Browser screen capture is unavailable in this environment.","DISPLAY_MEDIA_UNAVAILABLE");let t=await navigator.mediaDevices.getDisplayMedia({video:true,audio:false}),n=null;try{n=document.createElement("video"),n.muted=!0,n.playsInline=!0,n.srcObject=t,await fo(n);}catch(i){for(let u of t.getTracks())u.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(u=>u());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let u=i?.conceal??true,d=u?wn():()=>{};try{u&&await ho(r,3,400);let c=document.createElement("canvas");c.width=r.videoWidth,c.height=r.videoHeight;let m=c.getContext("2d");if(!m)throw new O("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");m.drawImage(r,0,0,c.width,c.height);let p=gt(),C=["Browser screen capture uses the window or tab selected by the user."],v={blob:await Cn(c,C),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?c.width/p.width:void 0,warnings:et(C)};return e.onWarning?.(v.warnings),v}finally{d();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function cn(e){let t=await Nt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function io(e,t){let n=gt(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:et(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function so(e){let t=new Set;e.querySelector("iframe")&&t.add("Embedded iframes may be blank or incomplete in DOM capture."),e.querySelector("video")&&t.add("Video frames may be blank or stale in DOM capture."),e.querySelector("canvas")&&t.add("Canvas/WebGL content may be blank if it is cross-origin tainted."),document.fonts&&document.fonts.status!=="loaded"&&t.add("Web fonts were still loading when the screenshot was captured.");let n=0;for(let r of Array.from(e.querySelectorAll("img"))){let o=r.currentSrc||r.src;if(o)try{new URL(o,window.location.href).origin!==window.location.origin&&!r.crossOrigin&&(n+=1);}catch{}}return n>0&&t.add(`${n} cross-origin image${n===1?"":"s"} without CORS may be omitted from the screenshot.`),Array.from(t)}async function Cn(e,t){let n=await dn(e,"image/png",.92);if(n.size<=Je)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>Je&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(Je/n.size)*.9)),i=document.createElement("canvas");i.width=Math.max(1,Math.round(r.width*a)),i.height=Math.max(1,Math.round(r.height*a));let u=i.getContext("2d");if(!u)return n;u.drawImage(r,0,0,i.width,i.height),r=i;for(let d of [.86,.74,.62,.5])if(n=await dn(r,"image/jpeg",d),n.size<=Je)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>Je&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function dn(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new O("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function gt(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function lo(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function uo(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??Zr;co()&&(o=Math.min(o,Xr));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(Qr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function co(){let e=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0||typeof window<"u"&&"ontouchstart"in window,t=document.documentElement.clientWidth||window.innerWidth||0;return e&&t>0&&t<=Jr}function mo(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var po=400;async function Rn(e){if(typeof document>"u"||typeof document.getAnimations!="function"||!(e>0))return;let t;try{t=document.getAnimations();}catch{return}let n=t.filter(a=>{if(a.playState!=="running")return false;let i=a.effect?.getComputedTiming?.();return !!i&&i.iterations!==1/0});if(n.length===0)return;let r=Promise.allSettled(n.map(a=>a.finished)).then(()=>{}),o=new Promise(a=>setTimeout(a,e));await Promise.race([r,o]);}function kn(){return !!navigator.mediaDevices?.getDisplayMedia}async function fo(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new O("Could not read screen capture video.","VIDEO_FAILED"));e.addEventListener("loadedmetadata",a,{once:true}),e.addEventListener("error",i,{once:true}),e.play().catch(i);});let t=performance.now(),n=1500;for(;e.videoWidth===0||e.videoHeight===0;){if(performance.now()-t>n)throw new O("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function ho(e,t,n){let r=e.requestVideoFrameCallback?.bind(e);if(typeof r!="function"){await new Promise(i=>setTimeout(i,Math.min(n,250)));return}let o=performance.now(),a=0;await new Promise(i=>{let u=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(u);};r(u),setTimeout(i,n);});}function At(){if(typeof window>"u"||typeof document>"u")throw new O("Screenshot capture can only run in the browser.","INVALID_ENV")}function et(e){return Array.from(new Set(e.filter(Boolean)))}var Sn=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,bo=[/-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )?PRIVATE KEY-----/g,/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,/\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA|ANVA|AIPA)[A-Z0-9]{16}\b/g,/\bgh[posru]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{18,}\b/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,/\bAIza[A-Za-z0-9_-]{35}\b/g,/\b[srp]k_(?:live|test)_[A-Za-z0-9]{10,}\b/g,/\bsk-(?:proj-|ant-)?[A-Za-z0-9_-]{32,}\b/g];function go(e){let t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return false;let n=0,r=false;for(let o=t.length-1;o>=0;o--){let a=t.charCodeAt(o)-48;r&&(a*=2,a>9&&(a-=9)),n+=a,r=!r;}return n%10===0}function Mt(e){let t=e;for(let n of bo)t=t.replace(n,"***");return t=t.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._\-+/=]+/gi,"$1 ***"),t=t.replace(/\b([A-Za-z_][\w-]*)"?\s*[=:]\s*("?)([^"\s&]{6,})\2/g,(n,r,o,a)=>/^(Bearer|Basic)$/i.test(a)?n:Sn.test(r)?`${r}=${o}***${o}`:a.length>=24&&/^[A-Za-z0-9._\-+/=]+$/.test(a)&&!a.includes(" ")?`${r}=${o}${a.slice(0,4)}\u2026${o}`:n),t=t.replace(/\b\d(?:[ -]?\d){12,18}\b/g,n=>go(n)?"***":n),t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***"),t=t.replace(/\b[\w.+-]+@[\w-]+\.[\w.-]+\b/g,"***@***"),t}function xn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])Sn.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Mt(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Mt(e)}}function Mn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return xn(e)}}var mn=200,pn=4096,Pn=[],ft=[],fn=false,Pt=null;function Tn(e={}){fn||typeof window>"u"||(fn=true,Pt=e.ignoreUrlPrefix??null,Eo(),Co(),Ro());}function vo(){return {consoleLog:Pn.slice(),networkLog:ft.slice()}}function ht(e,t){e.push(t),e.length>mn&&e.splice(0,e.length-mn);}function wo(e){let t=[];for(let r of e){if(typeof r=="string"){t.push(r);continue}if(r instanceof Error){t.push(`${r.name}: ${r.message}${r.stack?`
4
- ${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,yo));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>pn?n.slice(0,pn)+"\u2026[truncated]":n}function yo(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Eo(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let r=e[n]?.bind(e);r&&(e[n]=(...o)=>{try{ht(Pn,{level:n,ts:Date.now(),message:Mt(wo(o))});}catch{}r(...o);});}}function Ln(e){return Pt?e.startsWith(Pt):false}function Co(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let r=typeof t=="string"?t:t instanceof URL?t.toString():t.url,o=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(Ln(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ht(ft,{type:"fetch",method:o,url:Tt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ht(ft,{type:"fetch",method:o,url:Tt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Ro(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...a){return this.__lumen={method:String(r).toUpperCase(),url:typeof o=="string"?o:o.toString(),t:0},t.call(this,r,o,...a)},e.prototype.send=function(r){let o=this.__lumen;if(o&&!Ln(o.url)){o.t=performance.now();let a=()=>{try{ht(ft,{type:"xhr",method:o.method,url:Tt(o.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-o.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,r??null)};}function ko(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Tt(e){return ko(xn(e))}function Nn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:hn(e),consoleLog:[],networkLog:[]};let t=vo();return {url:Mn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:hn(e),device:So(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function So(){let e={};try{e.screen={width:window.screen?.width??0,height:window.screen?.height??0},e.pixelRatio=window.devicePixelRatio??1,e.language=navigator.language,e.languages=Array.from(navigator.languages??[]),e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,e.colorScheme=window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light",e.referrer=document.referrer?Mn(document.referrer):void 0,e.title=document.title||void 0,e.online=navigator.onLine,performance.getEntriesByType("navigation")[0]&&(e.uptimeMs=Math.round(performance.now()));}catch{}return e}function hn(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var xo="[data-lumen-root]",Mo="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function Po(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(Lt(n))return true;return Lt(e.target)}var bn=["pointerdown","mousedown","touchstart","click"];function To(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of bn)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of bn)e.removeEventListener(n,t);}}function Lt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(Mo)?true:!!e.closest(xo):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?Lt(e.host):false:false}var vt="lumen:shake",Lo=8e3,No=50,Ao=400;function Io(e={}){return async function(){if(typeof window>"u")throw new O("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=Oo(),n=e.send??Do,r=e.timeoutMs??Lo,o=e.captureSettleMs??No,a=e.awaitAnimationsMs??Ao,i=Uo(),u=wn(e.concealSelector===void 0?vn:e.concealSelector);try{await Ho(o,a);let d=await new Promise((p,C)=>{let v=window.setTimeout(()=>{t.pending.delete(i),C(new O("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:y=>{window.clearTimeout(v),p(y);},reject:y=>{window.clearTimeout(v),C(y);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(v),C(new O("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(d.error||!d.dataUrl)throw new O(d.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let c=Vo(d.dataUrl),m=e.platform??Fo();return {blob:c,method:m==="android"?"android-native":"ios-native",platform:m,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:d.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{u();}}}function Do(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new O("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function Oo(){if(window.__lumenNativeCapture)return window.__lumenNativeCapture;let e={pending:new Map,resolve(n,r,o){let a=e.pending.get(n);a&&(e.pending.delete(n),a.resolve({type:"lumen:capture-response",id:n,dataUrl:r,pixelRatio:o}));},reject(n,r){let o=e.pending.get(n);o&&(e.pending.delete(n),o.resolve({type:"lumen:capture-response",id:n,error:r}));}},t=n=>{let r=Bo(n.data);if(!r||r.type!=="lumen:capture-response")return;let o=e.pending.get(r.id);o&&(e.pending.delete(r.id),o.resolve(r));};return window.addEventListener("message",t),document.addEventListener("message",t),window.__lumenNativeCapture=e,e}function Bo(e){if(e&&typeof e=="object"&&"type"in e)return e;if(typeof e=="string")try{let t=JSON.parse(e);if(t&&typeof t=="object"&&t.type)return t}catch{}return null}async function Ho(e,t){await Rn(t),await _o(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function _o(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function Fo(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function Uo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function Vo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new O("Native host returned an invalid image data URL.","NATIVE_CAPTURE_FAILED");let n=t[1]||"image/png",r=!!t[2],o=t[3]??"";if(!r)return new Blob([decodeURIComponent(o)],{type:n});let a=atob(o),i=new Uint8Array(a.length);for(let u=0;u<a.length;u++)i[u]=a.charCodeAt(u);return new Blob([i],{type:n})}var tt="lumen:keyboardchange",It="--lumen-keyboard-inset";function zo(e){if(typeof window>"u")return;let t=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):0;window.__lumenKeyboardInset=t,typeof document<"u"&&document.documentElement.style.setProperty(It,`${t}px`),window.dispatchEvent(new Event(tt));}function Dt(){if(typeof window>"u")return null;let e=window.__lumenKeyboardInset;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof document<"u"&&typeof getComputedStyle=="function"){let t=getComputedStyle(document.documentElement).getPropertyValue(It).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function An(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new O("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new O("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(v=>MediaRecorder.isTypeSupported(v))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((v,y)=>{c=v,m=y;});p.catch(()=>{}),r.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&o.push(v.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let P of t.getTracks())P.stop();if(d)return;if(d=true,u){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let v=performance.now()-a,y=r.mimeType||n||"audio/webm",k=new Blob(o,{type:y});c({blob:k,durationMs:v,mimeType:y});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function C(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){u=true,C(),i!==null&&window.clearTimeout(i),i=null;for(let v of t.getTracks())v.stop();},stop(){return C(),p}}}async function In(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new O("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new O("Screen capture was denied or cancelled.","SCREEN_DENIED")}let n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(y=>MediaRecorder.isTypeSupported(y))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((y,k)=>{c=y,m=k;});p.catch(()=>{});function C(){i!==null&&(window.clearTimeout(i),i=null);for(let y of t.getTracks())y.stop();}r.addEventListener("dataavailable",y=>{y.data&&y.data.size>0&&o.push(y.data);}),r.addEventListener("stop",()=>{if(u)return;if(u=true,C(),d){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let y=r.mimeType||n||"video/webm";c({blob:new Blob(o,{type:y}),durationMs:performance.now()-a,mimeType:y});});function v(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(v,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",v),{stream:t,result:p,stop:v,cancel(){d=true,r.state!=="inactive"?r.stop():u||(u=true,C(),m(new O("Recording cancelled.","RECORDER_STOPPED")));}}}var Ot=createContext(null);function nt(){let e=useContext(Ot);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var Dn=100;function On(){if(typeof document>"u")return false;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;if(!e)return false;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?true:e.isContentEditable===true}var rt={open:false,inset:0};function jo(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:rt}if(e.vvHeight==null||!e.coarse||!e.editable)return rt;let n=e.vvBaseline-e.vvHeight;return n>Dn?{open:true,inset:Math.round(n)}:rt}function ot(e,t){let[n,r]=useState(rt),o=useRef(0),a=useRef(t);return a.current=t,useEffect(()=>{if(!e){r(rt);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,u=()=>{let p=On(),C=a.current,v=Dt(),y=window.visualViewport??null;y&&C==null&&v==null&&!p&&(o.current=y.height),r(jo({editable:p,override:C,injected:v,vvBaseline:o.current,vvHeight:y?y.height:null,coarse:i}));},d=0,c=()=>{d||(d=window.requestAnimationFrame(()=>{d=0,u();}));},m=window.visualViewport;return m&&(o.current=m.height),c(),m?.addEventListener("resize",c),m?.addEventListener("scroll",c),document.addEventListener("focusin",c),document.addEventListener("focusout",c),window.addEventListener(tt,c),()=>{d&&window.cancelAnimationFrame(d),m?.removeEventListener("resize",c),m?.removeEventListener("scroll",c),document.removeEventListener("focusin",c),document.removeEventListener("focusout",c),window.removeEventListener(tt,c);}},[e]),n}var Ht='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Hn(e,t=1){return Math.max(0,Math.min(t,e))}var Fn=_n.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},u){let d=useRef(null),c=useRef(null),m=useRef(null),[p,C]=useState(null),[v,y]=useState(false),[k,P]=useState(""),[S,T]=useState([]),b=useRef(null),E=useRef(false),B=useRef(0),N=useRef(false),[F,A]=useState([]),J=useRef(0),I=useRef([]),$=useRef([]),j=useRef(S);j.current=S;let W=useRef(F);W.current=F;let se=useRef(null),he=useRef(i);he.current=i;let V=useCallback(()=>{he.current?.({canUndo:I.current.length>0,canRedo:$.current.length>0});},[]),He=useCallback((h,w)=>{A(x=>x.map(M=>M.id===h?{...M,text:w}:M));},[]),_e=useCallback(h=>{A(x=>x.filter(M=>M.id!==h));let w=I.current.lastIndexOf("comment");w>=0&&I.current.splice(w,1),$.current=[],V();},[V]);useEffect(()=>{let h=se.current;if(h==null)return;se.current=null,m.current?.querySelector(`[data-bubble-id="${h}"] .lumen-bubble-text`)?.focus();},[F]),useEffect(()=>{T([]),A([]),y(false),I.current=[],$.current=[],V();},[t,V]),useEffect(()=>{let h=false,w=null;return (async()=>{try{let x=await createImageBitmap(t);if(h){x.close?.();return}w=x,C(x);}catch{}})(),()=>{h=true,w?.close?.();}},[t]),useEffect(()=>{if(!p)return;let h=d.current,w=c.current;if(!(!h||!w)){w.width=p.width,w.height=p.height;try{h.width=p.width,h.height=p.height;let x=h.getContext("2d");if(!x)return;x.imageSmoothingEnabled=!1,x.drawImage(p,0,0),y(!1);}catch{y(true);}}},[p]),useEffect(()=>{if(!v){P("");return}let h=URL.createObjectURL(t);return P(h),()=>{URL.revokeObjectURL(h);}},[v,t]),useEffect(()=>{let h=c.current;if(h)try{wt(h,S,b.current);}catch{}},[S]),useImperativeHandle(u,()=>({hasAnnotations:()=>S.length>0||F.some(h=>h.text.trim().length>0),reset:()=>{T([]),A([]),j.current=[],W.current=[],I.current=[],$.current=[],V();},undo:()=>{let h=I.current[I.current.length-1];if(h){if(h==="comment"){let w=W.current,x=w[w.length-1];if(!x)return;let M=w.slice(0,-1);W.current=M,$.current.push({type:"comment",item:x}),A(M);}else {let w=j.current,x=w[w.length-1];if(!x)return;let M=w.slice(0,-1);j.current=M,$.current.push({type:"anno",item:x}),T(M);}I.current.pop(),V();}},redo:()=>{let h=$.current[$.current.length-1];if(h){if(h.type==="comment"){let w=[...W.current,h.item];W.current=w,A(w);}else {let w=[...j.current,h.item];j.current=w,T(w);}I.current.push(h.type),$.current.pop(),V();}},async flatten(){let h=b.current,w=h?[...S,h]:S,x=F.filter(M=>M.text.trim().length>0);if(w.length===0&&x.length===0||!p||v)return t;try{let M=document.createElement("canvas");M.width=p.width,M.height=p.height;let _=M.getContext("2d");if(!_)return t;_.imageSmoothingEnabled=!1,_.drawImage(p,0,0);for(let re of w)_t(_,re);let K=d.current?.clientWidth||p.width,ne=p.width/Math.max(K,1);for(let re of x)Jo(_,re,p.width,p.height,ne);return await new Promise(re=>{M.toBlob(Ce=>{re(Ce??t);},"image/jpeg",.85);})}catch{return t}}}),[S,F,p,t,v,V]);function be(h){let w=c.current;if(!w)return {x:0,y:0};let x=w.getBoundingClientRect(),M=w.width/Math.max(x.width,1),_=w.height/Math.max(x.height,1);return {x:(h.clientX-x.left)*M,y:(h.clientY-x.top)*_}}function xe(){N.current||(N.current=true,requestAnimationFrame(()=>{N.current=false;let h=c.current;h&&wt(h,j.current,b.current);}));}function ye(h){if(h.button!==void 0&&h.button!==0)return;if(n==="comment"){let x=c.current;if(!x)return;let M=x.getBoundingClientRect(),_=Hn((h.clientX-M.left)/Math.max(M.width,1),.72),K=Hn((h.clientY-M.top)/Math.max(M.height,1),.8),ne=++J.current;A(re=>[...re,{id:ne,x:_,y:K,text:"",color:r}]),I.current.push("comment"),$.current=[],se.current=ne,V();return}try{h.currentTarget.setPointerCapture(h.pointerId);}catch{}E.current=true,a?.(true);let w=be(h);n==="arrow"?b.current={kind:"arrow",from:w,to:w,color:r,width:o}:n==="rect"?b.current={kind:"rect",from:w,to:w,color:r,width:o}:b.current={kind:"freehand",points:[w],color:r,width:o},B.current=performance.now(),xe();}function oe(h){if(!E.current||!b.current)return;let w=be(h),x=b.current;if(x.kind==="arrow"||x.kind==="rect")x.to=w;else {let M=x.points[x.points.length-1],_=M?(M.x-w.x)**2+(M.y-w.y)**2:1/0,K=performance.now(),ne=K-B.current;(_>16||ne>16)&&(x.points.push(w),B.current=K);}xe();}function Ee(){if(!E.current)return;E.current=false,a?.(false);let h=b.current;if(b.current=null,!!h){if(h.kind==="arrow"||h.kind==="rect"){let w=h.to.x-h.from.x,x=h.to.y-h.from.y;if(w*w+x*x<16){let M=c.current;M&&wt(M,j.current,null);return}}else if(h.points.length<2){let w=c.current;w&&wt(w,j.current,null);return}T(w=>[...w,h].slice(-50)),I.current.push("anno"),$.current=[],V();}}return jsxs("div",{ref:m,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsx("canvas",{ref:d}),v&&k?jsx("img",{src:k,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsx("canvas",{ref:c,className:"lumen-annotate-overlay",onPointerDown:ye,onPointerMove:oe,onPointerUp:Ee,onPointerCancel:Ee}),jsx("div",{className:"lumen-bubble-layer",children:F.map(h=>jsx(Zo,{comment:h,onChange:He,onRemove:_e},h.id))})]})});function Zo({comment:e,onChange:t,onRemove:n}){let r=useRef(null);return useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxs("div",{className:"lumen-bubble","data-bubble-id":e.id,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,"--lumen-bubble-accent":e.color},onPointerDown:o=>o.stopPropagation(),children:[jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsx("div",{ref:r,className:"lumen-bubble-text",contentEditable:true,suppressContentEditableWarning:true,role:"textbox","aria-label":"Comment text","data-placeholder":"Type a note\u2026",onInput:o=>t(e.id,o.currentTarget.textContent??"")}),jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function wt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)_t(r,o);n&&_t(r,n);}}function _t(e,t){if(e.save(),e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",t.kind==="rect"){let n=Math.min(t.from.x,t.to.x),r=Math.min(t.from.y,t.to.y),o=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,r,o,a);}else if(t.kind==="freehand")Xo(e,t.points);else {let{from:n,to:r,width:o}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke();let a=Math.atan2(r.y-n.y,r.x-n.x),i=Math.max(12,o*4);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(r.x-i*Math.cos(a-Math.PI/7),r.y-i*Math.sin(a-Math.PI/7)),e.lineTo(r.x-i*Math.cos(a+Math.PI/7),r.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function Xo(e,t){if(t.length===0)return;e.beginPath();let n=t[0];if(!n)return;if(e.moveTo(n.x,n.y),t.length===1){e.arc(n.x,n.y,e.lineWidth/2,0,Math.PI*2),e.fill();return}if(t.length===2){let o=t[1];e.lineTo(o.x,o.y),e.stroke();return}for(let o=1;o<t.length-1;o++){let a=t[o],i=t[o+1],u=(a.x+i.x)/2,d=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,u,d);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function Jo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,u=14*o,d=10*o,c=12*o,m=u*1.35,p=d*1.7,C=t.x*n,v=t.y*r,y=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${u}px ${Ht}`,e.textBaseline="top";let k=Qo(e,a,y-i*2),P=k.reduce((N,F)=>Math.max(N,e.measureText(F).width),0),S=Math.min(y,Math.max(P,56*o)+i*2),T=i*2+p+k.length*m;ea(e,C,v,S,T,c),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let b=C+18*o,E=v+T;e.beginPath(),e.moveTo(b,E-o),e.lineTo(b+13*o,E-o),e.lineTo(b+4*o,E+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${d}px ${Ht}`,e.fillText("COMMENT",C+i,v+i),e.fillStyle="#111318",e.font=`500 ${u}px ${Ht}`;let B=v+i+p;for(let N of k)e.fillText(N,C+i,B),B+=m;e.restore();}function Qo(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let u=a?`${a} ${i}`:i;a&&e.measureText(u).width>n?(o.push(a),a=i):a=u;}return a&&o.push(a),o.length?o:[t]}function ea(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function ee({children:e,...t}){return jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...t,children:e})}function ta(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M3 9a2 2 0 0 1 2-2h1.5l1-1.5h5l1 1.5H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function na(e){return jsxs(ee,{...e,children:[jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Ft(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function Vn(e){return jsx(ee,{...e,children:jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-8.5 8.5 9.5 9.5 0 0 1-3.5-.7L3 21l1.7-5.5A8.38 8.38 0 0 1 4 11.5 8.5 8.5 0 0 1 12.5 3 8.38 8.38 0 0 1 21 11.5Z"})})}function zn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M5 19 19 5"}),jsx("path",{d:"M11 5h8v8"})]})}function $n(e){return jsx(ee,{...e,children:jsx("rect",{x:"4",y:"6",width:"16",height:"12",rx:"2"})})}function Ut(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M5 19l1.5-5L16 4.5 19.5 8 10 17.5 5 19z"}),jsx("path",{d:"M14 6.5l3.5 3.5"})]})}function Wn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M9 8 4 13l5 5"}),jsx("path",{d:"M4 13h11a5 5 0 0 1 0 10h-1"})]})}function Vt(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),jsx("path",{d:"M21 4v4h-4"})]})}function Kn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M15 8 20 13l-5 5"}),jsx("path",{d:"M20 13H9a5 5 0 0 0 0 10h1"})]})}function qn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M4 7h16"}),jsx("path",{d:"M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"}),jsx("path",{d:"M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"})]})}function jn(e){return jsx(ee,{...e,strokeWidth:2.2,children:jsx("path",{d:"M15 6l-6 6 6 6"})})}function Yn(e){return jsx(ee,{...e,strokeWidth:1.9,children:jsx("path",{d:"M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z"})})}function it(e){return jsxs(ee,{...e,children:[jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsx("path",{d:"M8 21h8M12 17v4"})]})}function zt(e){return jsxs(ee,{...e,children:[jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var yt={shot:ta,video:na,upload:Ft};function Gn(e){let t=e.videoWidth||1280,n=e.videoHeight||720,r=document.createElement("canvas");r.width=t,r.height=n;let o=r.getContext("2d");return o?(o.drawImage(e,0,0,t,n),new Promise(a=>r.toBlob(i=>a(i),"image/jpeg",.82))):Promise.resolve(null)}function ra(e,t){return !Number.isFinite(t)||t<=0?Promise.resolve():new Promise(n=>{e.addEventListener("seeked",()=>n(),{once:true});try{e.currentTime=t;}catch{n();}})}var oa=4e3;async function $t(e){if(typeof document>"u")return {poster:null,durationMs:0};let t=URL.createObjectURL(e),n=document.createElement("video");n.muted=true,n.playsInline=true,n.preload="auto",n.src=t;let r=async()=>{await new Promise((d,c)=>{if(n.readyState>=2)return d();n.addEventListener("loadeddata",()=>d(),{once:true}),n.addEventListener("error",()=>c(new Error("video decode failed")),{once:true});}),await ra(n,Math.min(.1,(n.duration||0)/2));let i=await Gn(n),u=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:u}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),oa);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Wt(e){if(typeof document>"u")return null;let t=document.createElement("video");t.muted=true,t.playsInline=true,t.srcObject=e;try{return await t.play().catch(()=>{}),await new Promise(n=>{if(t.readyState>=2)return n();t.addEventListener("loadeddata",()=>n(),{once:!0}),window.setTimeout(n,600);}),await Gn(t)}catch{return null}finally{t.srcObject=null;}}async function Kt(){if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=1280,e.height=720;let t=e.getContext("2d");return t?(t.fillStyle="#0e0e12",t.fillRect(0,0,e.width,e.height),t.fillStyle="#52525b",t.beginPath(),t.moveTo(590,312),t.lineTo(590,408),t.lineTo(694,360),t.closePath(),t.fill(),new Promise(n=>e.toBlob(r=>n(r),"image/jpeg",.8))):null}var qt=60,aa=25*1024*1024,Zn=[{label:"Red",value:"rgb(239, 68, 68)"},{label:"Amber",value:"rgb(245, 158, 11)"},{label:"Blue",value:"rgb(59, 130, 246)"},{label:"Green",value:"rgb(34, 197, 94)"},{label:"Neutral",value:"rgb(244, 244, 245)"}],Xn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],ia=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],sa=[{value:"",label:"No priority"},{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],la=[{value:"web",label:"Web"},{value:"ios-native",label:"iOS native"},{value:"android-native",label:"Android native"}];function ua(e){return e.platform==="ios"?"ios-native":e.platform==="android"?"android-native":e.platform==="custom"?"custom":"web"}function ca({value:e}){return e==="urgent"?jsx("span",{className:"lumen-pri-ic lumen-pri-urgent","aria-hidden":"true",children:"!"}):jsxs("span",{className:"lumen-pri-ic lumen-pri-bars","data-level":e==="high"?3:e==="medium"?2:1,"aria-hidden":"true",children:[jsx("i",{}),jsx("i",{}),jsx("i",{})]})}var jt=[{value:"shot",label:"Screenshot",hint:"This page, instantly",primary:true},{value:"video",label:"Video",hint:"Record up to 60s"},{value:"upload",label:"Upload",hint:"Image or video"}];function Yt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:u,consumePendingVideo:d,canRecordScreen:c,consumeRecordStartError:m,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:v,keyboardInset:y}=nt(),[k,P]=useState(1),[S,T]=useState(null),[b,E]=useState({kind:"idle"}),[B,N]=useState(false),[F,A]=useState(0),[J,I]=useState("arrow"),[$,j]=useState(Zn[0].value),[W,se]=useState(Xn[1].value),[he,V]=useState(""),[He,_e]=useState("bug"),[be,xe]=useState(""),[ye,oe]=useState(""),[Ee,h]=useState(false),[w,x]=useState(false),[M,_]=useState(false),[K,ne]=useState(false),[re,Ce]=useState(r?.email??""),[z,ae]=useState(null),[q,Me]=useState(null),[Fe,Re]=useState(0),[ke,Se]=useState(null),[Ze,Pe]=useState(null),[lt,ut]=useState(false),[le,Te]=useState({canUndo:false,canRedo:false}),Y=useRef(null),We=useRef(null),ge=useRef(null),Le=useRef(null),Ke=useRef(null),Ne=ot(t,y),ve=useRef(false),qe=useRef(false);useEffect(()=>{t||(qe.current=false);},[t]),useEffect(()=>{if(!t)return;if(qe.current){ve.current=false;return}qe.current=true,ve.current=false,P(1),T(null),V(""),Me(null),Re(0),Se(null),N(false),A(0),oe(""),Pe(null),Te({canUndo:false,canRedo:false});let s=C();if(s){T("shot"),me(s),E({kind:"ready",capture:s});return}let g=d();if(g)T("video"),Se({blob:g.blob,durationMs:g.durationMs}),g.blob.size>aa&&toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),g.poster?E({kind:"ready",capture:Qe(g.poster,["Screen recording; preview is the first frame."])}):(E({kind:"capturing"}),(async()=>{let D=null;if(g.deriveBlobPoster)try{D=(await $t(g.blob)).poster;}catch{D=null;}D=D??await Kt(),!ve.current&&E(D?{kind:"ready",capture:Qe(D,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let D=m();D?(T("video"),Pe(D),E({kind:"idle"})):a?(T("shot"),E({kind:"ready",capture:a})):o?.mode==="manual"?E({kind:"manual"}):o?.provider&&!i?(T("shot"),Ue(o.mode??"auto")):E({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ve.current=true;}},[t,o,a,i]),useEffect(()=>{if(!t)return;Ke.current=document.activeElement??null;let s=document.documentElement,g=s.style.overflow,D=s.style.paddingRight,ie=window.innerWidth-s.clientWidth;s.style.overflow="hidden",ie>0&&(s.style.paddingRight=`${ie}px`);let ue=false,we=()=>{if(!ue){ue=true,s.style.overflow=g,s.style.paddingRight=D;try{Ke.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",we),()=>{window.removeEventListener("pagehide",we),we();}},[t]),useEffect(()=>{if(!t)return;function s(g){if(g.key==="Escape"){g.preventDefault(),n();return}if(g.key!=="Tab")return;let D=ge.current;if(!D)return;let ie=ya(D);if(ie.length===0)return;let ue=ie[0],we=ie[ie.length-1],xt=document.activeElement;g.shiftKey&&(xt===ue||!D.contains(xt))?(g.preventDefault(),we.focus()):!g.shiftKey&&xt===we&&(g.preventDefault(),ue.focus());}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),useEffect(()=>{if(!t||!v)return;let s=Le.current;if(!s)return;let g=D=>{D.target===s&&D.stopPropagation();};return s.addEventListener("pointerdown",g),s.addEventListener("click",g),s.addEventListener("touchstart",g,{passive:true}),()=>{s.removeEventListener("pointerdown",g),s.removeEventListener("click",g),s.removeEventListener("touchstart",g);}},[t,v]),useEffect(()=>{if(!t||!Ne.open)return;let s=ge.current,g=document.activeElement;if(s&&g&&s.contains(g))try{g.scrollIntoView({block:"center"});}catch{}},[t,Ne.open,Ne.inset]),useEffect(()=>{if(!t||b.kind!=="manual")return;function s(g){let ue=Array.from(g.clipboardData?.items??[]).find(we=>we.type.startsWith("image/"))?.getAsFile();ue&&(g.preventDefault(),Xe(ue));}return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[t,b.kind]),useEffect(()=>{if(!z)return;let s=Date.now(),g=window.setInterval(()=>{let D=Math.floor((Date.now()-s)/1e3);Re(D),D>=qt&&U();},250);return ()=>window.clearInterval(g)},[z]);let Ae=useRef(null);if(Ae.current=z,useEffect(()=>{t||Ae.current&&(Ae.current.cancel(),Ae.current=null,ae(null),Re(0));},[t]),useEffect(()=>()=>{Ae.current?.cancel();},[]),!t)return null;async function Ue(s){ve.current=false,E({kind:"capturing"});try{let g=await bt({...o,mode:s,target:o?.target??document.documentElement});return ve.current?!1:(me(g),E({kind:"ready",capture:g}),!0)}catch(g){return ve.current||E({kind:"manual",error:g instanceof Error?g.message:"Automatic screenshot capture was unavailable."}),false}}async function Ie(s){T(s),Pe(null),s!=="video"&&St(),s==="shot"?await Ue(o?.mode??"auto"):s==="video"?(Se(null),E({kind:"idle"})):(E({kind:"manual"}),We.current?.click());}async function Xe(s){if(s.type.startsWith("image/")){St();let g=Qe(s,["Manual image upload used."]);E({kind:"ready",capture:g});return}if(s.type.startsWith("video/")){E({kind:"capturing"});try{let{poster:g,durationMs:D}=await $t(s),ie=g??await Kt();if(!ie){E({kind:"manual",error:"Could not read that video."});return}let ue=Qe(ie,["Uploaded video; preview is the first frame."]);Se({blob:s,durationMs:D}),E({kind:"ready",capture:ue});}catch{E({kind:"manual",error:"Could not read that video."});}return}toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function me(s){s.warnings.length!==0&&toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function R(){try{let s=await An(qt);ae(s);}catch(s){toast.error(s instanceof Error?s.message:"Microphone unavailable");}}async function U(){if(z)try{let s=await z.stop();Me({blob:s.blob,durationMs:s.durationMs});}catch(s){toast.error(s instanceof Error?s.message:"Could not stop recording");}finally{ae(null);}}function G(){z?.cancel(),ae(null),Me(null),Re(0);}function ct(s){let g=jsxs("div",{className:"lumen-audio-row",children:[!z&&!q?jsxs("button",{type:"button",onClick:R,className:s==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsx(zt,{}),"Record voice note"]}):null,z?jsxs(Fragment,{children:[jsxs("span",{className:"lumen-recording",children:[jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsx(ha,{stream:z.stream}),jsxs("span",{className:"lumen-rec-time",children:[Fe,"s / ",qt,"s"]})]}),jsx("button",{type:"button",onClick:U,className:"lumen-btn-ghost",children:"Stop"}),jsx("button",{type:"button",onClick:G,className:"lumen-btn-ghost",children:"Cancel"})]}):null,q&&!z?jsxs(Fragment,{children:[jsx(ga,{blob:q.blob,durationMs:q.durationMs}),jsx("button",{type:"button",onClick:()=>Me(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return s==="capture"?jsxs("div",{className:"lumen-voice-capture",children:[g,!z&&!q?jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxs("div",{className:"lumen-label",children:[jsx("span",{children:"Add a voice note (optional)"}),g]})}async function Or(){Pe(null);try{await u();}catch(s){toast.error(s instanceof Error?s.message:"Screen capture unavailable");}}function St(){Se(null);}let Br=b.kind==="ready";async function Jt(){z&&await U(),k===1?(b.kind==="ready"&&!ye&&oe(ua(b.capture)),P(2)):await en();}function Qt(){k>1&&P(s=>s-1);}async function en(){if(b.kind!=="ready")return;let s=he.trim(),{capture:g}=b;N(true),A(0);try{let ie=await Y.current?.flatten()??g.blob,ue=await e.submit({rawText:s.length>0?s:void 0,category:He,priority:be||void 0,source:ye||void 0,submitterEmail:re.trim()||void 0,screenshot:ie,audio:q?.blob,audioDurationMs:q?.durationMs,video:ke?.blob,videoDurationMs:ke?.durationMs,context:Nn(g)},{onUploadProgress:we=>A(Math.min(.95,we))});A(1),toast.success("Feedback sent \u2014 thank you."),ue.id,n();}catch(D){toast.error(D instanceof Error?D.message:"Could not submit feedback"),N(false);}}function Hr(s){s.target===s.currentTarget&&!B&&n();}let je=Math.round(F*100),dt=S==="video",_r=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,tn=S==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&_r,nn=k===1&&!Br||B,Fr=k<3?"Next":B?je<95?`Uploading ${je}%\u2026`:"Almost done\u2026":"Send feedback",mt=k===1,rn=k===2&&b.kind==="ready",Ur=mt||rn;return jsx("div",{ref:Le,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Ne.inset?{"--lumen-keyboard-inset":`${Ne.inset}px`}:void 0,onMouseDown:Hr,children:jsxs("div",{ref:ge,className:"lumen-modal","data-lumen-drawing":lt?"true":void 0,"data-lumen-fs":Ur?"true":void 0,"data-lumen-review":rn?"true":void 0,"data-lumen-sheet":mt&&w?"down":void 0,children:[jsx(fa,{onDismiss:n}),jsxs("header",{className:"lumen-modal-header",children:[jsxs("h2",{className:"lumen-modal-title",children:[jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsx(da,{step:k}),jsx("input",{ref:We,type:"file",accept:"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime",style:{display:"none"},onChange:s=>{let g=s.currentTarget.files?.[0];g&&Xe(g),s.currentTarget.value="";}}),jsxs("div",{className:"lumen-modal-body",children:[k===1||k===2?jsx("div",{className:"lumen-pane",children:S===null?jsxs(Fragment,{children:[jsx("div",{className:"lumen-fs-top",children:jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})})}),jsxs("div",{className:"lumen-fs-center lumen-fs-picker",children:[jsxs("div",{className:"lumen-fs-picker-head",children:[jsx("div",{className:"lumen-fs-picker-title",children:"How do you want to capture?"}),jsx("div",{className:"lumen-fs-picker-sub",children:"Pick a method to report this."})]}),jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxs("button",{type:"button",className:"lumen-method-btn"+(s.primary?" lumen-method-primary":""),onClick:()=>Ie(s.value),disabled:b.kind==="capturing",children:[jsx("span",{className:"lumen-method-ico",children:jsx(g,{})}),s.primary?jsxs(Fragment,{children:[jsxs("span",{className:"lumen-method-text",children:[jsx("span",{className:"lumen-method-label",children:s.label}),jsx("span",{className:"lumen-method-hint",children:s.hint})]}),jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxs(Fragment,{children:[jsx("span",{className:"lumen-method-label",children:s.label}),jsx("span",{className:"lumen-method-hint",children:s.hint})]})]},s.value)})})]})]}):jsxs(Fragment,{children:[b.kind!=="ready"?jsxs(Fragment,{children:[jsxs("div",{className:"lumen-fs-top",children:[jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})}),jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsx("div",{className:"lumen-fs-pill",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>Ie(s.value),disabled:b.kind==="capturing",children:jsx(g,{})},s.value)})})})]}),jsxs("div",{className:"lumen-fs-center",children:[S==="video"&&b.kind==="idle"?jsx(ma,{canRecord:c,onRecord:Or,onUpload:()=>Ie("upload"),error:Ze}):null,b.kind==="capturing"?jsxs("p",{className:"lumen-status",children:[jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,b.kind==="manual"?jsxs("div",{className:"lumen-manual-capture",children:[jsx("p",{className:"lumen-status",children:S==="upload"?"Choose an image or video to attach \u2014 or paste an image.":b.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxs("label",{className:"lumen-manual-drop",children:[jsx("span",{children:S==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsx("input",{type:"file",accept:S==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:s=>{let g=s.currentTarget.files?.[0];g&&Xe(g),s.currentTarget.value="";}})]})]}):null]})]}):null,b.kind==="ready"?jsxs(Fragment,{children:[k===1?jsxs(Fragment,{children:[jsxs("div",{className:"lumen-fs-top",children:[jsxs("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:[jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"}),jsxs("div",{className:"lumen-fs-recap",children:[jsxs("button",{type:"button",className:"lumen-fs-chip",onClick:()=>_(s=>!s),"aria-haspopup":"menu","aria-expanded":M,children:[jsx(Vt,{})," Recapture",jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},"aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),M?jsxs(Fragment,{children:[jsx("div",{className:"lumen-fs-recap-overlay",onClick:()=>_(false)}),jsxs("div",{className:"lumen-fs-recap-menu",role:"menu",children:[jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),S&&Ie(S);},children:[jsx("span",{className:"lumen-fs-mi-ic",children:jsx(Vt,{})}),jsxs("span",{children:[jsx("b",{children:"Re-snap this view"}),jsx("small",{children:"Instant \xB7 masks sensitive fields"})]})]}),tn?jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),p();},children:[jsx("span",{className:"lumen-fs-mi-ic",children:jsx(it,{})}),jsxs("span",{children:[jsx("b",{children:"Capture exact pixels"}),jsx("small",{children:"Real screen \u2014 canvas, video & charts"})]})]}):null]})]}):null]})]}),jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxs("div",{className:"lumen-fs-pill",role:"group","aria-label":"Tools and capture method",children:[dt?null:jsxs(Fragment,{children:[jsx("button",{type:"button",className:"lumen-fs-pill-btn lumen-fs-pentog","data-on":!Ee,onClick:()=>h(s=>!s),"aria-label":"Toggle markup tools",title:"Toggle markup tools",children:jsx(Ut,{})}),jsx("span",{className:"lumen-fs-pill-sep"})]}),jt.map(s=>{let g=yt[s.value];return jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>Ie(s.value),children:jsx(g,{})},s.value)})]})})]}),!dt&&!Ee?jsxs("div",{className:"lumen-toolbar",children:[jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsx(Et,{label:"Arrow",icon:jsx(zn,{}),active:J==="arrow",onClick:()=>I("arrow")}),jsx(Et,{label:"Box",icon:jsx($n,{}),active:J==="rect",onClick:()=>I("rect")}),jsx(Et,{label:"Draw",icon:jsx(Ut,{}),active:J==="freehand",onClick:()=>I("freehand")}),jsx(Et,{label:"Comment",icon:jsx(Vn,{}),active:J==="comment",onClick:()=>I("comment")})]}),jsx("span",{className:"lumen-toolbar-sep"}),jsxs("div",{className:"lumen-fs-color",children:[jsx("button",{type:"button",className:"lumen-fs-color-btn",style:{background:$},"aria-label":"Pick colour","aria-haspopup":"true","aria-expanded":K,onClick:()=>ne(s=>!s)}),K?jsxs(Fragment,{children:[jsx("div",{className:"lumen-fs-color-overlay",onClick:()=>ne(false)}),jsx("div",{className:"lumen-fs-color-pop",role:"group","aria-label":"Colour",children:Zn.map(s=>jsx("button",{type:"button",className:"lumen-swatch",style:{background:s.value},"aria-label":s.label,"aria-pressed":$===s.value,onClick:()=>{j(s.value),ne(false);}},s.value))})]}):null]}),mt?null:jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Xn.map(s=>jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":s.label,"aria-pressed":W===s.value,onClick:()=>se(s.value),children:jsx("span",{className:"lumen-stroke-size-dot",style:{width:s.dot,height:s.dot}})},s.value))}),mt?null:jsx("span",{className:"lumen-toolbar-spacer"}),jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.undo(),disabled:!le.canUndo,"aria-label":"Undo",title:"Undo",children:jsx(Wn,{})}),jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.redo(),disabled:!le.canRedo,"aria-label":"Redo",title:"Redo",children:jsx(Kn,{})}),jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.reset(),disabled:!le.canUndo,"aria-label":"Clear",title:"Clear",children:jsx(qn,{})})]}):null]}):null,jsx("div",{className:"lumen-annotate",children:jsx(Fn,{ref:Y,screenshot:b.capture.blob,tool:J,color:$,strokeWidth:W,onDrawingChange:ut,onHistoryChange:Te})}),k===1?jsxs(Fragment,{children:[jsxs("div",{className:"lumen-cap-actions",children:[jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>S&&Ie(S),children:dt?"\u21BB Re-record":"\u21BB Recapture"}),tn?jsxs("button",{type:"button",className:"lumen-btn-ghost lumen-exact-btn",onClick:()=>{p();},title:"Capture the real screen pixels \u2014 your browser will ask which tab or window to share, then you arrange the page and press Capture.",children:[jsx(it,{})," Capture exact screen"]}):null,dt?ke?jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ke.durationMs/1e3),"s recorded"]}):null:jsx("span",{className:"lumen-cap-note",children:b.capture.method==="web-display-media"?"Exact screen captured":`${Jn(S)} captured \xB7 switch method above anytime`})]}),jsxs("div",{className:"lumen-fs-compose",children:[jsx("button",{type:"button",className:"lumen-fs-grab",onClick:()=>x(s=>!s),"aria-label":w?"Expand sheet":"Minimize sheet"}),jsxs("div",{className:"lumen-fs-field",children:[jsx("input",{className:"lumen-input lumen-fs-desc",value:he,onChange:s=>V(s.target.value),placeholder:"Describe what's wrong \u2014 or use voice"}),jsx("button",{type:"button",className:"lumen-fs-mic",onClick:R,"aria-label":"Record voice note",children:jsx(zt,{})})]}),ct("capture"),jsx("button",{type:"button",className:"lumen-btn-primary lumen-fs-next",onClick:Jt,disabled:nn,children:"Next"})]})]}):null]}):null]})}):null,k===2?jsxs("div",{className:"lumen-pane lumen-rv-pane",children:[jsx("div",{className:"lumen-rv-scrim","aria-hidden":"true"}),jsxs("div",{className:"lumen-rv",children:[jsxs("div",{className:"lumen-rv-head",children:[jsxs("button",{type:"button",className:"lumen-rv-back",onClick:Qt,children:[jsx(jn,{}),"Back"]}),jsx("span",{className:"lumen-rv-title",children:"Review & send"}),jsx("span",{className:"lumen-rv-spacer","aria-hidden":"true"})]}),jsxs("div",{className:"lumen-rv-rows",children:[jsxs("div",{className:"lumen-rv-set",children:[jsxs("span",{className:"lumen-rv-k",children:["Description"," ",jsx("span",{className:"lumen-rv-muted",children:"\xB7 tap to edit"})]}),jsx("textarea",{className:"lumen-input lumen-rv-desc",value:he,onChange:s=>V(s.target.value),rows:2,placeholder:"Describe what's wrong\u2026"})]}),jsxs("div",{className:"lumen-rv-set",children:[jsx("span",{className:"lumen-rv-k",children:"Type"}),jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Type",children:ia.map(s=>jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":He===s.value,onClick:()=>_e(s.value),children:s.label},s.value))})]}),jsxs("div",{className:"lumen-rv-set",children:[jsx("span",{className:"lumen-rv-k",children:"Priority"}),jsx("div",{className:"lumen-rv-prio",role:"group","aria-label":"Priority",children:sa.filter(s=>s.value!=="").map(s=>jsxs("button",{type:"button",className:"lumen-rv-prio-opt","aria-pressed":be===s.value,onClick:()=>xe(be===s.value?"":s.value),children:[jsx(ca,{value:s.value}),s.label]},s.value))})]}),jsxs("div",{className:"lumen-rv-set",children:[jsxs("span",{className:"lumen-rv-k",children:["Platform"," ",jsx("span",{className:"lumen-rv-muted",children:"\xB7 auto-detected \u2014 change if wrong"})]}),jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Platform",children:la.map(s=>jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":ye===s.value,onClick:()=>oe(s.value),children:s.label},s.value))})]}),jsxs("div",{className:"lumen-rv-row",children:[jsx("span",{className:"lumen-rv-rk",children:"Capture"}),jsxs("span",{className:"lumen-rv-rv",children:[Jn(S),le.canUndo?" \xB7 annotated":"",jsx("button",{type:"button",className:"lumen-edit",onClick:()=>P(1),children:"edit"})]})]}),ct("describe"),jsx("div",{className:"lumen-rv-attachrow",children:ke?jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ke.durationMs/1e3),"s",jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:St,children:"\xD7"})]}):jsxs("label",{className:"lumen-rv-attach",children:[jsx(Ft,{}),"Attach a video",jsx("input",{type:"file",accept:"video/mp4,video/webm,video/quicktime",onChange:s=>{let g=s.currentTarget.files?.[0];g&&Se({blob:g,durationMs:0}),s.currentTarget.value="";}})]})})]}),jsx("button",{type:"button",className:"lumen-btn-primary lumen-rv-send",onClick:en,disabled:B,children:B?je<95?`Uploading ${je}%\u2026`:"Almost done\u2026":jsxs(Fragment,{children:[jsx(Yn,{}),"Send feedback"]})})]})]}):null]}),jsxs("footer",{className:"lumen-modal-footer",children:[B?jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":je,children:jsx("div",{className:"lumen-progress-fill",style:{width:`${je}%`}})}):null,jsxs("div",{className:"lumen-modal-actions",children:[jsx("button",{type:"button",onClick:k===1?n:Qt,className:"lumen-btn-ghost",disabled:B,children:k===1?"Cancel":"Back"}),jsx("button",{type:"button",onClick:Jt,className:"lumen-btn-primary",disabled:nn,children:Fr})]})]})]})})}function Jn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function da({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsx("span",{className:"lumen-step-num",children:n.n}),jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function ma({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxs("div",{className:"lumen-record-prompt",children:[r?jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxs("div",{className:"lumen-record-copy",children:[jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsx("div",{className:"lumen-record-sub",children:"Tap to start. The sheet closes so you can record freely \u2014 a Stop button stays on screen, then the sheet returns with your clip. Max 60s."})]})]}):jsxs("div",{className:"lumen-record-prompt",children:[jsx("p",{className:"lumen-record-unavailable",children:pa()?jsx(Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsx(Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function pa(){if(typeof navigator>"u")return false;let e=navigator.userAgent||"";return /iPad|iPhone|iPod/.test(e)?true:/Macintosh/.test(e)&&typeof document<"u"&&"ontouchend"in document}function Et({label:e,active:t,onClick:n,icon:r}){return jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,"aria-label":r?e:void 0,title:e,children:r??e})}function fa({onDismiss:e}){let t=useRef(null),n=useRef(0),r=useRef(null);function o(u){u.currentTarget.setPointerCapture(u.pointerId),t.current=u.clientY,n.current=performance.now(),r.current=u.currentTarget.parentElement;}function a(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current);r.current.style.transform=`translateY(${d}px)`;}function i(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current),c=Math.max(1,performance.now()-n.current),m=d/c;r.current.style.transform="",r.current.style.transition="",t.current=null,(d>80||m>.6)&&e();}return jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function ha({stream:e}){let t=useRef(null);return useEffect(()=>{let n=t.current;if(!n)return;let r=Math.min(window.devicePixelRatio||1,2),o=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(o*r),n.height=Math.round(a*r);let i=n.getContext("2d");if(!i)return;i.scale(r,r);let u=window.AudioContext??window.webkitAudioContext;if(!u)return;let d=new u,c=d.createMediaStreamSource(e),m=d.createAnalyser();m.fftSize=1024,m.smoothingTimeConstant=.6,c.connect(m);let p=new Uint8Array(m.fftSize),C=18,v=3,y=3,k=Math.max(2,(o-v*(C-1))/C),P=Math.min(k/2,3),S=new Array(C).fill(0),T=0,b=false;function E(){if(b)return;m.getByteTimeDomainData(p);let B=Math.floor(p.length/C);i.clearRect(0,0,o,a),i.fillStyle=va("--lumen-danger")||"rgb(239,68,68)";for(let N=0;N<C;N++){let F=0;for(let W=0;W<B;W++){let se=Math.abs((p[N*B+W]??128)-128);se>F&&(F=se);}let A=Math.min(1,F/128*1.8),J=S[N]??0;S[N]=A>J?A:J+(A-J)*.35;let I=Math.max(y,S[N]*a),$=N*(k+v),j=(a-I)/2;ba(i,$,j,k,I,P),i.fill();}T=requestAnimationFrame(E);}return T=requestAnimationFrame(E),()=>{b=true,cancelAnimationFrame(T);try{c.disconnect();}catch{}d.close();}},[e]),jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function ba(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function ga({blob:e,durationMs:t}){let[n,r]=useState("");return useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxs("div",{className:"lumen-audio-preview",children:[jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function va(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var wa='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function ya(e){return Array.from(e.querySelectorAll(wa)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var Ct=class extends _n.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t,n){if(typeof document<"u"){let r=document.documentElement;r.style.overflow="",r.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),toast.error("Feedback widget hit a snag and was reset. Please try again.");try{let r=t instanceof Error?t:null;this.props.onError?.({message:r?.message??String(t),name:r?.name??"Error",stack:r?.stack,componentStack:n?.componentStack??void 0});}catch{}Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function rr({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=useState(false);if(useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?createPortal(jsx(Ca,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):createPortal(jsxs("div",{className:"lumen-rec-hud lumen-rec-hud-pending",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function Ca({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=useState(0);useEffect(()=>{let u=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));u();let d=window.setInterval(u,250);return ()=>window.clearInterval(d)},[e,t]);let i=u=>`${Math.floor(u/60)}:${String(u%60).padStart(2,"0")}`;return jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function or({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=useState(false);if(useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,u=e.phase==="grabbing";return createPortal(jsxs("div",{className:"lumen-cap-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[u?jsx("span",{className:"lumen-cap-hud-spinner","aria-hidden":"true"}):jsx("span",{className:"lumen-cap-hud-ico","aria-hidden":"true",children:jsx(it,{})}),jsx("span",{className:"lumen-cap-hud-text",children:u?"Capturing\u2026":"Arrange the screen, then capture"}),jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:u,children:"Cancel"}),jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:u,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Gt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function ar(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function ir(e){return e instanceof Error?e:new Error(String(e))}function sr(e,t,n){let r=false,o=false,a=false,i=null;function u(){o||(o=true,n.onCancelled());}function d(m){o||(o=true,n.onResult(m));}function c(m){o||(o=true,n.onError(m));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(m=>{if(i=m,r){try{m.cancel();}catch{}u();return}if(n.onActive(m),a){n.onProcessing();try{m.stop();}catch{}}Promise.resolve(m.result).then(p=>{r?u():d(p);}).catch(p=>{r||ar(p)?u():c(ir(p));});}).catch(m=>{r||ar(m)?u():c(ir(m));}),{stop(){if(!(o||r||a)&&(a=true,i)){n.onProcessing();try{i.stop();}catch{}}},cancel(){if(!(o&&r)){if(r=true,i)try{i.cancel();}catch{}u();}}}}function lr(){if(typeof document>"u"||typeof window>"u")return 0;let e=window.innerWidth,t=window.innerHeight;if(e===0||t===0)return 0;let n=t-4,r=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],o=new Set,a=0;for(let i of r){let u=document.elementsFromPoint(i,n);for(let d of u){if(o.has(d))continue;o.add(d);let c=window.getComputedStyle(d);if(c.position!=="fixed"&&c.position!=="sticky")continue;let m=d.getBoundingClientRect();m.bottom<t-8||m.bottom>t+8||m.width<e*.6||m.height>a&&(a=m.height);}}return a}function Zt(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,r=window.innerHeight,o=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let u of Array.from(i)){let d=u.getBoundingClientRect();if(d.height===0||d.width===0)continue;let c=0;switch(t){case "bottom":if(d.bottom<r-8)break;c=Math.max(0,r-d.top);break;case "top":if(d.top>8)break;c=Math.max(0,d.bottom);break;case "left":if(d.left>8)break;c=Math.max(0,d.right);break;case "right":if(d.right<n-8)break;c=Math.max(0,n-d.left);break}c>o&&(o=c);}}return o}function ur(e){let[t,n]=useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=useRef(t),o=La(e.avoid),a=e.placement,i=e.offset.x,u=e.offset.y;return useEffect(()=>{if(typeof window>"u")return;let d=0,c=false,m=()=>{if(d=0,c)return;let k=a[0]==="b"?"bottom":"top",P=a[1]==="r"?"right":"left",S=0,T=0;e.avoid==="auto"&&k==="bottom"?S=lr():Array.isArray(e.avoid)&&(S=Zt(e.avoid,k),T=Zt(e.avoid,P));let b={bottom:k==="bottom"?u+S:0,top:k==="top"?u+S:0,right:P==="right"?i+T:0,left:P==="left"?i+T:0},E=r.current;(b.bottom!==E.bottom||b.top!==E.top||b.right!==E.right||b.left!==E.left)&&(r.current=b,n(b));},p=()=>{d||(d=window.requestAnimationFrame(m));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let v=typeof MutationObserver<"u"?new MutationObserver(p):null;v?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let y=window.visualViewport;return y?.addEventListener("resize",p),y?.addEventListener("scroll",p),()=>{c=true,d&&window.cancelAnimationFrame(d),C?.disconnect(),v?.disconnect(),window.removeEventListener("resize",p),y?.removeEventListener("resize",p),y?.removeEventListener("scroll",p);}},[a,i,u,o]),t}function La(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var cr=["mousedown","touchstart"];function Ge(e){let t=useRef(e.onPointerDown);t.current=e.onPointerDown;let n=useRef(e.onClick);n.current=e.onClick;let r=useRef(e.isolate??true);r.current=e.isolate??true;let o=useRef(null);return useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=c=>{r.current&&c.stopPropagation(),t.current?.(c);},u=c=>{r.current&&c.stopPropagation(),n.current(c);},d=c=>{r.current&&c.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",u);for(let c of cr)a.addEventListener(c,d,c==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",u);for(let c of cr)a.removeEventListener(c,d);};},[])}function fr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[u,d]=useState(null),c=useRef(null),m=ur(e),p=ot(e.keyboard!=="off",i),C=Ge({onPointerDown:r,onClick:o,isolate:a}),v=useCallback(A=>{c.current=A,C(A);},[C]);useEffect(()=>{typeof document>"u"||d(t??document.body);},[t]);let y=e.placement,k=y[0]==="b"?"bottom":"top",P=y[1]==="r"?"right":"left",S=k==="bottom",T=p.open&&S&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,b=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&S&&p.inset<=0);if(Oa(c,!n&&!b),!u)return null;let E=k==="bottom"?m.bottom:m.top,B=P==="right"?m.right:m.left,N=n||b,F={position:"fixed",[k]:e.safeArea?`calc(${E}px + env(safe-area-inset-${k}, 0px))`:`${E}px`,[P]:e.safeArea?`calc(${B}px + env(safe-area-inset-${P}, 0px))`:`${B}px`,zIndex:e.zIndex,transform:T?`translateY(-${T}px)`:void 0,opacity:N?0:1,pointerEvents:N?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return createPortal(jsxs("button",{ref:v,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:F,"aria-label":e.label,"aria-hidden":N?true:void 0,tabIndex:N?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsx("span",{children:e.label})]}),u)}function Oa(e,t){let n=useRef(false);useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let r=window.setTimeout(()=>{let o=e.current;if(!o)return;let a=o.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,u=a.top+a.height/2,d=document.elementsFromPoint(i,u),c=dr(window.getComputedStyle(o).zIndex);for(let m of d){if(m===o||o.contains(m))continue;if(dr(window.getComputedStyle(m).zIndex)>c){n.current=true,console.warn("[lumen] trigger is occluded by",m);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function dr(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function hr({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=useState(null),d=Ge({onPointerDown:r,onClick:o,isolate:a});return useEffect(()=>{if(typeof document>"u")return;let c=e instanceof HTMLElement?e:e.current??null;u(c);},[e]),i?createPortal(jsxs("button",{ref:d,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsx("span",{children:t})]}),i):null}function vr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=useState(null),[d,c]=useState(false),m=useRef(null),p=Ge({onPointerDown:P=>{r?.(P),m.current={x:P.clientX,y:P.clientY},c(true);let S=P.currentTarget;try{S?.setPointerCapture?.(P.pointerId);}catch{}},onClick:o,isolate:a});if(useEffect(()=>{typeof document>"u"||u(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${d?" lumen-notch-expanded":""}`;function v(P){let S=m.current;if(!S)return;let T=P.clientX-S.x,b=P.clientY-S.y;(e.edge==="top"&&b>16||e.edge==="bottom"&&b<-16||e.edge==="right"&&T<-16||e.edge==="left"&&T>16)&&(m.current=null,o(P.nativeEvent));}function y(){m.current=null,c(false);}function k(){m.current=null,c(false);}return createPortal(jsxs("button",{ref:p,type:"button",className:C,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:v,onPointerUp:y,onPointerCancel:k,onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function wr(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function ja(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function yr(e){return {kind:"floating",placement:e.placement??"br",offset:{x:e.offset?.x??16,y:e.offset?.y??16},safeArea:e.safeArea??true,avoid:e.avoid===false?false:e.avoid==null?"auto":Array.isArray(e.avoid)?e.avoid:[e.avoid],keyboard:ja(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Za={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function Er(e){let t=useId();useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${Xa(t)}`,o={},a=(i,u)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,u);};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else {for(let[i,u]of Object.entries(Za)){let d=e[u];typeof d=="string"&&d.length>0&&a(i,d);}typeof e.accent=="string"&&e.accent.length>0&&(a("--lumen-accent",e.accent),a("--lumen-primary",e.accent),a("--lumen-accent-fg","#ffffff")),(e.scheme==="light"||e.scheme==="dark")&&(o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e.scheme));}return n.setAttribute(r,""),()=>{n.removeAttribute(r);for(let[i,u]of Object.entries(o))i.startsWith("--")?u?n.style.setProperty(i,u):n.style.removeProperty(i):u==null?n.removeAttribute(i):n.setAttribute(i,u);}},[e,t]);}function Xa(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Cr=Symbol.for("lumen.history.patched"),Xt="lumen:locationchange";function ei(){if(typeof window>"u")return;let e=window;if(e[Cr])return;e[Cr]=true;let t=()=>window.dispatchEvent(new Event(Xt)),n=history.pushState;history.pushState=function(...o){let a=n.apply(this,o);return t(),a};let r=history.replaceState;history.replaceState=function(...o){let a=r.apply(this,o);return t(),a},window.addEventListener("popstate",t);}function Rr(e){let[t,n]=useState(false);return useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;ei();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Xt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Xt,r),window.removeEventListener("popstate",r);}},[e]),t}var ri=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function kr(){let[e,t]=useState(false);return useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let r=n.webkit;if(r&&r.messageHandlers){t(true);return}let o=navigator.userAgent||"";ri.some(a=>o.includes(a))&&t(true);},[]),e}var xr="lumen.config.v1.",ii=3600*1e3;function Mr(e,t){let[n,r]=useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return useEffect(()=>{if(typeof window>"u")return;let o=mi(e);o&&r({trigger:o.trigger,enabled:Sr(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),u=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(u,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.json(),m=Pr(c.trigger);if(!m)throw new Error("Malformed config response");let p=ui(c.trigger),C=Tr(c.brand);pi(e,m,p,C),r({trigger:m,enabled:Sr(m),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(d=>d.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:d);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Sr(e){return e.kind!=="headless"}var si=["br","bl","tr","tl"],li=["top","right","bottom","left"];function Pr(e){if(!e||typeof e!="object")return null;let t=e;if(t.enabled===false)return {kind:"headless"};let n=typeof t.label=="string"?t.label:"Feedback";return t.kind==="floating"?{kind:"floating",placement:si.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:li.find(o=>o===t.edge)??"top",label:n}:null}function ui(e){return !e||typeof e!="object"?false:e.shake===true}var ci=/^#[0-9a-fA-F]{6}$/,di=["auto","light","dark"];function Tr(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&ci.test(t.accent)?t.accent:null;if(!n)return null;let r=di.find(a=>a===t.mode)??"auto",o=typeof t.radius=="number"&&Number.isFinite(t.radius)?Math.min(20,Math.max(0,Math.round(t.radius))):10;return {accent:n,mode:r,radius:o}}function mi(e){try{let t=window.localStorage.getItem(xr+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>ii)return null;let r=Pr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:Tr(n.brand)}:null}catch{return null}}function pi(e,t,n,r){try{window.localStorage.setItem(xr+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function hi(e){if(e&&typeof e=="object")return e.type===vt;if(typeof e=="string")try{return JSON.parse(e).type===vt}catch{return false}return false}function bi(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(u,d,c,m){if(!a)return a={x:u,y:d,z:c,t:m},false;if(m-a.t<o)return false;let p=Math.abs(u-a.x)+Math.abs(d-a.y)+Math.abs(c-a.z);return a={x:u,y:d,z:c,t:m},p<t?false:(i=i.filter(C=>m-C<r),i.push(m),i.length>=n?(i=[],true):false)}}}function Lr(e,t,n){useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let m=Date.now();n||m-r<o||(r=m,t());}let i=m=>{hi(m.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let u=bi(),d=m=>{let p=m.accelerationIncludingGravity??m.acceleration;!p||p.x==null||p.y==null||p.z==null||u.push(p.x,p.y,p.z,Date.now())&&a();},c=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return c&&window.addEventListener("devicemotion",d),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),c&&window.removeEventListener("devicemotion",d);}},[e,t,n]);}var Ar="https://shakebugs.vercel.app",kt=60;function Ir(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function wi({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:u,portalTarget:d,capture:c,record:m,shakeToOpen:p,onOpenChange:C,beforeOpen:v,onTriggerActivate:y,isolateEvents:k=true,keyboardInset:P,suppressTrigger:S=false,children:T}){let[b,E]=useState(false),[B,N]=useState(false),[F,A]=useState(null),[J,I]=useState(null),[$]=useState(false),[j]=useState(null),W=useRef(false),se=useRef(false),he=useRef(null),V=useMemo(()=>new gn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);useEffect(()=>{Tn({ignoreUrlPrefix:(t??Ar).replace(/\/$/,"")});},[t]);let He=useRef(C);He.current=C,useEffect(()=>{if(!(typeof document>"u"))return b?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[b]);let _e=useRef(null);useEffect(()=>{if(_e.current===b)return;let R=_e.current;_e.current=b,R!==null&&He.current?.(b);},[b]);let be=useRef(v);be.current=v;let xe=useRef(y);xe.current=y;let ye=useCallback(R=>{se.current=true,he.current=Promise.resolve().then(()=>be.current?.(R)).then(()=>xe.current?.(R)).then(()=>{});},[]),oe=useCallback(R=>{W.current||b||ae.current||ge.current||(W.current=true,N(true),A(null),I(null),(async()=>{try{if(se.current?await he.current:(await be.current?.(R),await xe.current?.(R)),c?.mode==="manual")A(null),I(null);else if(c?.provider)A(null),I(null);else {let U=await bt({...c,mode:c?.mode??"auto",target:c?.target??document.documentElement});A(U);}}catch(U){I(U instanceof Error?U:new Error(String(U)));}finally{se.current=false,he.current=null,W.current=false,N(false),E(true);}})());},[c,b]),Ee=useCallback(()=>{E(false),A(null),I(null);},[]),h=useCallback(V.submit.bind(V),[V]),[w,x]=useState(0),M=useCallback(()=>{W.current=false,N(false),E(false),A(null),I(null),x(R=>R+1);},[]),[_,K]=useState(null),[ne,re]=useState(null),Ce=useRef(null),z=useRef(null),ae=useRef(false),q=useRef(null),Me=useRef(null),Fe=useRef(null),Re=useCallback((R,U=false)=>{if(Ce.current=null,z.current=null,ae.current=false,K(null),!R){q.current=null;return}Me.current={blob:R.blob,durationMs:R.durationMs,poster:q.current,deriveBlobPoster:U},q.current=null,E(true);},[]);useEffect(()=>{if(!b)return;if(!m?.provider){re(null);return}let R=m.isAvailable;if(!R){re(true);return}let U=false;return Promise.resolve().then(()=>R()).then(G=>{U||re(G);}).catch(()=>{U||re(false);}),()=>{U=true;}},[b,m?.provider,m?.isAvailable]);let ke=Gt({hasProvider:!!m?.provider,providerAvailable:ne,hasGetDisplayMedia:Ir()}).canRecord,Se=useCallback(async()=>{if(ae.current)return;if(Fe.current=null,Gt({hasProvider:!!m?.provider,providerAvailable:ne,hasGetDisplayMedia:Ir()}).usingProvider&&m?.provider){ae.current=true,q.current=null,E(false),z.current=sr(m.provider,{maxDurationSeconds:kt},{onStarting:()=>K({phase:"starting"}),onActive:G=>{K({phase:"recording",stream:G.stream??null,startedAt:Date.now(),maxSeconds:kt}),G.stream&&Wt(G.stream).then(ct=>{q.current=ct;}).catch(()=>{});},onProcessing:()=>K({phase:"processing"}),onResult:G=>Re({blob:G.blob,durationMs:G.durationMs},true),onCancelled:()=>{z.current=null,ae.current=false,q.current=null,K(null),A(null),I(null),E(true);},onError:G=>{z.current=null,ae.current=false,q.current=null,K(null),Fe.current=G.message||"Screen recording could not start.",E(true);}});return}if(Ce.current)return;let U=await In(kt);Ce.current=U,ae.current=true,q.current=null,K({phase:"recording",stream:U.stream,startedAt:Date.now(),maxSeconds:kt}),E(false),Wt(U.stream).then(G=>{q.current=G;}).catch(()=>{}),U.result.then(G=>Re(G)).catch(()=>Re(null));},[Re,m?.provider,ne]),Ze=useCallback(()=>{z.current?z.current.stop():Ce.current?.stop();},[]),Pe=useCallback(()=>{if(z.current){z.current.cancel();return}let R=Ce.current;Ce.current=null,ae.current=false,q.current=null,K(null),R?.cancel(),A(null),I(null),E(true);},[]),lt=useCallback(()=>{let R=Me.current;return Me.current=null,R},[]),ut=useCallback(()=>{let R=Fe.current;return Fe.current=null,R},[]);useEffect(()=>{b||(Fe.current=null);},[b]);let[le,Te]=useState(null),Y=useRef(null),We=useRef(null),ge=useRef(false),Le=useCallback(()=>{let R=Y.current;Y.current=null,ge.current=false,R?.stop(),Te(null),E(true);},[]),Ke=useCallback(()=>{let R=Y.current;R&&(Te({phase:"grabbing"}),(async()=>{try{let U=await R.grab();if(Y.current!==R)return;We.current=U,Y.current=null,ge.current=!1,R.stop(),Te(null),E(!0);}catch{if(Y.current!==R)return;Y.current=null,ge.current=false,R.stop(),Te(null),toast.error("Could not capture the screen. Please try again."),E(true);}})());},[]),Ne=useCallback(async()=>{if(ge.current)return;let R;try{R=await Nt({...c});}catch{return}Y.current=R,ge.current=true,R.onEnded(()=>Le()),Te({phase:"live"}),E(false);},[c,Le]),ve=useCallback(()=>{let R=We.current;return We.current=null,R},[]);useEffect(()=>()=>{Y.current?.stop(),Y.current=null;},[]);let qe=kr(),Ae=Rr(i),Ue=Mr(a?"":e,t??Ar);Er(u??Ci(Ue.brand));let Ie=p??Ue.shakeToOpen;Lr(Ie,oe,b);let Xe=useMemo(()=>({client:V,user:n,isOpen:b,isSubmitting:$,error:j,open:oe,close:Ee,openCapture:oe,closeCapture:Ee,submit:h,isNativeShell:qe,capture:c,initialCapture:F,initialCaptureError:J,isOpening:B,startVideoSession:Se,stopVideoSession:Ze,cancelVideoSession:Pe,recording:_,consumePendingVideo:lt,canRecordScreen:ke,consumeRecordStartError:ut,startScreenCaptureSession:Ne,grabScreenCaptureFrame:Ke,cancelScreenCaptureSession:Le,screenCapture:le,consumePendingScreenshot:ve,isolateEvents:k,keyboardInset:P}),[V,n,b,$,j,oe,Ee,h,qe,c,F,J,Se,Ze,Pe,_,lt,ke,ut,Ne,Ke,Le,le,ve,B,k,P]),me=Ei({explicit:a,remote:Ue.trigger,remoteLoading:Ue.loading,floatingButton:o});return jsxs(Ot.Provider,{value:Xe,children:[T,jsxs(Ct,{onReset:M,onError:R=>V.reportClientError({...R,context:{open:b,opening:B,screenCapturePhase:le?.phase,recordingPhase:_?.phase,initialCaptureMethod:F?.method,initialCapturePixelRatio:F?.pixelRatio,initialCaptureViewport:F?.viewport,hadInitialCaptureError:J!=null}}),children:[me?.kind==="floating"?jsx(fr,{config:yr(me),portalTarget:d,hidden:Ae||S||B||_!=null||le!=null,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k,keyboardInset:P}):null,me?.kind==="notch"?jsx(vr,{config:wr(me),portalTarget:d,hidden:Ae||S||B||_!=null||le!=null,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k}):null,me?.kind==="inline"?jsx(hr,{mount:me.mount,label:me.label??"Feedback",icon:me.icon,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k}):null,le?jsx(or,{state:le,portalTarget:d,onCapture:Ke,onCancel:Le}):null,_?jsx(rr,{state:_,portalTarget:d,onStop:Ze,onCancel:Pe}):null,jsx(Yt,{})]},w),jsx(yi,{})]})}function yi(){let[e,t]=useState(false);return useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsx(Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Ei(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Ci(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Ri({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=nt(),u=["lumen-btn",e==="default"?"lumen-btn-primary":null,e==="ghost"?"lumen-btn-ghost":null,e==="outline"?"lumen-btn-outline":null,t?"lumen-btn-floating":null,n].filter(Boolean).join(" ");return jsx("button",{type:"button",className:u,"data-lumen-trigger":"",onClick:d=>{o?.(d),d.defaultPrevented||i(d.nativeEvent);},...a,children:r})}
4
+ ${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,yo));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>pn?n.slice(0,pn)+"\u2026[truncated]":n}function yo(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Eo(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let r=e[n]?.bind(e);r&&(e[n]=(...o)=>{try{ht(Pn,{level:n,ts:Date.now(),message:Mt(wo(o))});}catch{}r(...o);});}}function Ln(e){return Pt?e.startsWith(Pt):false}function Co(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let r=typeof t=="string"?t:t instanceof URL?t.toString():t.url,o=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(Ln(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ht(ft,{type:"fetch",method:o,url:Tt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ht(ft,{type:"fetch",method:o,url:Tt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Ro(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...a){return this.__lumen={method:String(r).toUpperCase(),url:typeof o=="string"?o:o.toString(),t:0},t.call(this,r,o,...a)},e.prototype.send=function(r){let o=this.__lumen;if(o&&!Ln(o.url)){o.t=performance.now();let a=()=>{try{ht(ft,{type:"xhr",method:o.method,url:Tt(o.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-o.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,r??null)};}function ko(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Tt(e){return ko(xn(e))}function Nn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:hn(e),consoleLog:[],networkLog:[]};let t=vo();return {url:Mn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:hn(e),device:So(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function So(){let e={};try{e.screen={width:window.screen?.width??0,height:window.screen?.height??0},e.pixelRatio=window.devicePixelRatio??1,e.language=navigator.language,e.languages=Array.from(navigator.languages??[]),e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,e.colorScheme=window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light",e.referrer=document.referrer?Mn(document.referrer):void 0,e.title=document.title||void 0,e.online=navigator.onLine,performance.getEntriesByType("navigation")[0]&&(e.uptimeMs=Math.round(performance.now()));}catch{}return e}function hn(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var xo="[data-lumen-root]",Mo="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function Po(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(Lt(n))return true;return Lt(e.target)}var bn=["pointerdown","mousedown","touchstart","click"];function To(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of bn)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of bn)e.removeEventListener(n,t);}}function Lt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(Mo)?true:!!e.closest(xo):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?Lt(e.host):false:false}var vt="lumen:shake",Lo=8e3,No=50,Ao=400;function Io(e={}){return async function(){if(typeof window>"u")throw new O("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=Oo(),n=e.send??Do,r=e.timeoutMs??Lo,o=e.captureSettleMs??No,a=e.awaitAnimationsMs??Ao,i=Uo(),u=wn(e.concealSelector===void 0?vn:e.concealSelector);try{await Ho(o,a);let d=await new Promise((p,C)=>{let v=window.setTimeout(()=>{t.pending.delete(i),C(new O("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:y=>{window.clearTimeout(v),p(y);},reject:y=>{window.clearTimeout(v),C(y);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(v),C(new O("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(d.error||!d.dataUrl)throw new O(d.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let c=Vo(d.dataUrl),m=e.platform??Fo();return {blob:c,method:m==="android"?"android-native":"ios-native",platform:m,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:d.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{u();}}}function Do(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new O("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function Oo(){if(window.__lumenNativeCapture)return window.__lumenNativeCapture;let e={pending:new Map,resolve(n,r,o){let a=e.pending.get(n);a&&(e.pending.delete(n),a.resolve({type:"lumen:capture-response",id:n,dataUrl:r,pixelRatio:o}));},reject(n,r){let o=e.pending.get(n);o&&(e.pending.delete(n),o.resolve({type:"lumen:capture-response",id:n,error:r}));}},t=n=>{let r=Bo(n.data);if(!r||r.type!=="lumen:capture-response")return;let o=e.pending.get(r.id);o&&(e.pending.delete(r.id),o.resolve(r));};return window.addEventListener("message",t),document.addEventListener("message",t),window.__lumenNativeCapture=e,e}function Bo(e){if(e&&typeof e=="object"&&"type"in e)return e;if(typeof e=="string")try{let t=JSON.parse(e);if(t&&typeof t=="object"&&t.type)return t}catch{}return null}async function Ho(e,t){await Rn(t),await _o(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function _o(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function Fo(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function Uo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function Vo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new O("Native host returned an invalid image data URL.","NATIVE_CAPTURE_FAILED");let n=t[1]||"image/png",r=!!t[2],o=t[3]??"";if(!r)return new Blob([decodeURIComponent(o)],{type:n});let a=atob(o),i=new Uint8Array(a.length);for(let u=0;u<a.length;u++)i[u]=a.charCodeAt(u);return new Blob([i],{type:n})}var tt="lumen:keyboardchange",It="--lumen-keyboard-inset";function zo(e){if(typeof window>"u")return;let t=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):0;window.__lumenKeyboardInset=t,typeof document<"u"&&document.documentElement.style.setProperty(It,`${t}px`),window.dispatchEvent(new Event(tt));}function Dt(){if(typeof window>"u")return null;let e=window.__lumenKeyboardInset;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof document<"u"&&typeof getComputedStyle=="function"){let t=getComputedStyle(document.documentElement).getPropertyValue(It).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function An(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new O("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new O("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(v=>MediaRecorder.isTypeSupported(v))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((v,y)=>{c=v,m=y;});p.catch(()=>{}),r.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&o.push(v.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let P of t.getTracks())P.stop();if(d)return;if(d=true,u){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let v=performance.now()-a,y=r.mimeType||n||"audio/webm",k=new Blob(o,{type:y});c({blob:k,durationMs:v,mimeType:y});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function C(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){u=true,C(),i!==null&&window.clearTimeout(i),i=null;for(let v of t.getTracks())v.stop();},stop(){return C(),p}}}async function In(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new O("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new O("Screen capture was denied or cancelled.","SCREEN_DENIED")}let n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(y=>MediaRecorder.isTypeSupported(y))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((y,k)=>{c=y,m=k;});p.catch(()=>{});function C(){i!==null&&(window.clearTimeout(i),i=null);for(let y of t.getTracks())y.stop();}r.addEventListener("dataavailable",y=>{y.data&&y.data.size>0&&o.push(y.data);}),r.addEventListener("stop",()=>{if(u)return;if(u=true,C(),d){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let y=r.mimeType||n||"video/webm";c({blob:new Blob(o,{type:y}),durationMs:performance.now()-a,mimeType:y});});function v(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(v,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",v),{stream:t,result:p,stop:v,cancel(){d=true,r.state!=="inactive"?r.stop():u||(u=true,C(),m(new O("Recording cancelled.","RECORDER_STOPPED")));}}}var Ot=createContext(null);function nt(){let e=useContext(Ot);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var Dn=100;function On(){if(typeof document>"u")return false;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;if(!e)return false;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?true:e.isContentEditable===true}var rt={open:false,inset:0};function jo(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:rt}if(e.vvHeight==null||!e.coarse||!e.editable)return rt;let n=e.vvBaseline-e.vvHeight;return n>Dn?{open:true,inset:Math.round(n)}:rt}function ot(e,t){let[n,r]=useState(rt),o=useRef(0),a=useRef(t);return a.current=t,useEffect(()=>{if(!e){r(rt);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,u=()=>{let p=On(),C=a.current,v=Dt(),y=window.visualViewport??null;y&&C==null&&v==null&&!p&&(o.current=y.height),r(jo({editable:p,override:C,injected:v,vvBaseline:o.current,vvHeight:y?y.height:null,coarse:i}));},d=0,c=()=>{d||(d=window.requestAnimationFrame(()=>{d=0,u();}));},m=window.visualViewport;return m&&(o.current=m.height),c(),m?.addEventListener("resize",c),m?.addEventListener("scroll",c),document.addEventListener("focusin",c),document.addEventListener("focusout",c),window.addEventListener(tt,c),()=>{d&&window.cancelAnimationFrame(d),m?.removeEventListener("resize",c),m?.removeEventListener("scroll",c),document.removeEventListener("focusin",c),document.removeEventListener("focusout",c),window.removeEventListener(tt,c);}},[e]),n}var Ht='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Hn(e,t=1){return Math.max(0,Math.min(t,e))}var Fn=_n.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},u){let d=useRef(null),c=useRef(null),m=useRef(null),[p,C]=useState(null),[v,y]=useState(false),[k,P]=useState(""),[S,T]=useState([]),b=useRef(null),E=useRef(false),B=useRef(0),N=useRef(false),[F,A]=useState([]),J=useRef(0),I=useRef([]),$=useRef([]),j=useRef(S);j.current=S;let W=useRef(F);W.current=F;let se=useRef(null),he=useRef(i);he.current=i;let V=useCallback(()=>{he.current?.({canUndo:I.current.length>0,canRedo:$.current.length>0});},[]),He=useCallback((h,w)=>{A(x=>x.map(M=>M.id===h?{...M,text:w}:M));},[]),_e=useCallback(h=>{A(x=>x.filter(M=>M.id!==h));let w=I.current.lastIndexOf("comment");w>=0&&I.current.splice(w,1),$.current=[],V();},[V]);useEffect(()=>{let h=se.current;if(h==null)return;se.current=null,m.current?.querySelector(`[data-bubble-id="${h}"] .lumen-bubble-text`)?.focus();},[F]),useEffect(()=>{T([]),A([]),y(false),I.current=[],$.current=[],V();},[t,V]),useEffect(()=>{let h=false,w=null;return (async()=>{try{let x=await createImageBitmap(t);if(h){x.close?.();return}w=x,C(x);}catch{}})(),()=>{h=true,w?.close?.();}},[t]),useEffect(()=>{if(!p)return;let h=d.current,w=c.current;if(!(!h||!w)){w.width=p.width,w.height=p.height;try{h.width=p.width,h.height=p.height;let x=h.getContext("2d");if(!x)return;x.imageSmoothingEnabled=!1,x.drawImage(p,0,0),y(!1);}catch{y(true);}}},[p]),useEffect(()=>{if(!v){P("");return}let h=URL.createObjectURL(t);return P(h),()=>{URL.revokeObjectURL(h);}},[v,t]),useEffect(()=>{let h=c.current;if(h)try{wt(h,S,b.current);}catch{}},[S]),useImperativeHandle(u,()=>({hasAnnotations:()=>S.length>0||F.some(h=>h.text.trim().length>0),reset:()=>{T([]),A([]),j.current=[],W.current=[],I.current=[],$.current=[],V();},undo:()=>{let h=I.current[I.current.length-1];if(h){if(h==="comment"){let w=W.current,x=w[w.length-1];if(!x)return;let M=w.slice(0,-1);W.current=M,$.current.push({type:"comment",item:x}),A(M);}else {let w=j.current,x=w[w.length-1];if(!x)return;let M=w.slice(0,-1);j.current=M,$.current.push({type:"anno",item:x}),T(M);}I.current.pop(),V();}},redo:()=>{let h=$.current[$.current.length-1];if(h){if(h.type==="comment"){let w=[...W.current,h.item];W.current=w,A(w);}else {let w=[...j.current,h.item];j.current=w,T(w);}I.current.push(h.type),$.current.pop(),V();}},async flatten(){let h=b.current,w=h?[...S,h]:S,x=F.filter(M=>M.text.trim().length>0);if(w.length===0&&x.length===0||!p||v)return t;try{let M=document.createElement("canvas");M.width=p.width,M.height=p.height;let _=M.getContext("2d");if(!_)return t;_.imageSmoothingEnabled=!1,_.drawImage(p,0,0);for(let re of w)_t(_,re);let K=d.current?.clientWidth||p.width,ne=p.width/Math.max(K,1);for(let re of x)Jo(_,re,p.width,p.height,ne);return await new Promise(re=>{M.toBlob(Ce=>{re(Ce??t);},"image/jpeg",.85);})}catch{return t}}}),[S,F,p,t,v,V]);function be(h){let w=c.current;if(!w)return {x:0,y:0};let x=w.getBoundingClientRect(),M=w.width/Math.max(x.width,1),_=w.height/Math.max(x.height,1);return {x:(h.clientX-x.left)*M,y:(h.clientY-x.top)*_}}function xe(){N.current||(N.current=true,requestAnimationFrame(()=>{N.current=false;let h=c.current;h&&wt(h,j.current,b.current);}));}function ye(h){if(h.button!==void 0&&h.button!==0)return;if(n==="comment"){let x=c.current;if(!x)return;let M=x.getBoundingClientRect(),_=Hn((h.clientX-M.left)/Math.max(M.width,1),.72),K=Hn((h.clientY-M.top)/Math.max(M.height,1),.8),ne=++J.current;A(re=>[...re,{id:ne,x:_,y:K,text:"",color:r}]),I.current.push("comment"),$.current=[],se.current=ne,V();return}try{h.currentTarget.setPointerCapture(h.pointerId);}catch{}E.current=true,a?.(true);let w=be(h);n==="arrow"?b.current={kind:"arrow",from:w,to:w,color:r,width:o}:n==="rect"?b.current={kind:"rect",from:w,to:w,color:r,width:o}:b.current={kind:"freehand",points:[w],color:r,width:o},B.current=performance.now(),xe();}function oe(h){if(!E.current||!b.current)return;let w=be(h),x=b.current;if(x.kind==="arrow"||x.kind==="rect")x.to=w;else {let M=x.points[x.points.length-1],_=M?(M.x-w.x)**2+(M.y-w.y)**2:1/0,K=performance.now(),ne=K-B.current;(_>16||ne>16)&&(x.points.push(w),B.current=K);}xe();}function Ee(){if(!E.current)return;E.current=false,a?.(false);let h=b.current;if(b.current=null,!!h){if(h.kind==="arrow"||h.kind==="rect"){let w=h.to.x-h.from.x,x=h.to.y-h.from.y;if(w*w+x*x<16){let M=c.current;M&&wt(M,j.current,null);return}}else if(h.points.length<2){let w=c.current;w&&wt(w,j.current,null);return}T(w=>[...w,h].slice(-50)),I.current.push("anno"),$.current=[],V();}}return jsxs("div",{ref:m,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsx("canvas",{ref:d}),v&&k?jsx("img",{src:k,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsx("canvas",{ref:c,className:"lumen-annotate-overlay",onPointerDown:ye,onPointerMove:oe,onPointerUp:Ee,onPointerCancel:Ee}),jsx("div",{className:"lumen-bubble-layer",children:F.map(h=>jsx(Zo,{comment:h,onChange:He,onRemove:_e},h.id))})]})});function Zo({comment:e,onChange:t,onRemove:n}){let r=useRef(null);return useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxs("div",{className:"lumen-bubble","data-bubble-id":e.id,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,"--lumen-bubble-accent":e.color},onPointerDown:o=>o.stopPropagation(),children:[jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsx("div",{ref:r,className:"lumen-bubble-text",contentEditable:true,suppressContentEditableWarning:true,role:"textbox","aria-label":"Comment text","data-placeholder":"Type a note\u2026",onInput:o=>t(e.id,o.currentTarget.textContent??"")}),jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function wt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)_t(r,o);n&&_t(r,n);}}function _t(e,t){if(e.save(),e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",t.kind==="rect"){let n=Math.min(t.from.x,t.to.x),r=Math.min(t.from.y,t.to.y),o=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,r,o,a);}else if(t.kind==="freehand")Xo(e,t.points);else {let{from:n,to:r,width:o}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke();let a=Math.atan2(r.y-n.y,r.x-n.x),i=Math.max(12,o*4);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(r.x-i*Math.cos(a-Math.PI/7),r.y-i*Math.sin(a-Math.PI/7)),e.lineTo(r.x-i*Math.cos(a+Math.PI/7),r.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function Xo(e,t){if(t.length===0)return;e.beginPath();let n=t[0];if(!n)return;if(e.moveTo(n.x,n.y),t.length===1){e.arc(n.x,n.y,e.lineWidth/2,0,Math.PI*2),e.fill();return}if(t.length===2){let o=t[1];e.lineTo(o.x,o.y),e.stroke();return}for(let o=1;o<t.length-1;o++){let a=t[o],i=t[o+1],u=(a.x+i.x)/2,d=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,u,d);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function Jo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,u=14*o,d=10*o,c=12*o,m=u*1.35,p=d*1.7,C=t.x*n,v=t.y*r,y=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${u}px ${Ht}`,e.textBaseline="top";let k=Qo(e,a,y-i*2),P=k.reduce((N,F)=>Math.max(N,e.measureText(F).width),0),S=Math.min(y,Math.max(P,56*o)+i*2),T=i*2+p+k.length*m;ea(e,C,v,S,T,c),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let b=C+18*o,E=v+T;e.beginPath(),e.moveTo(b,E-o),e.lineTo(b+13*o,E-o),e.lineTo(b+4*o,E+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${d}px ${Ht}`,e.fillText("COMMENT",C+i,v+i),e.fillStyle="#111318",e.font=`500 ${u}px ${Ht}`;let B=v+i+p;for(let N of k)e.fillText(N,C+i,B),B+=m;e.restore();}function Qo(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let u=a?`${a} ${i}`:i;a&&e.measureText(u).width>n?(o.push(a),a=i):a=u;}return a&&o.push(a),o.length?o:[t]}function ea(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function ee({children:e,...t}){return jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...t,children:e})}function ta(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M3 9a2 2 0 0 1 2-2h1.5l1-1.5h5l1 1.5H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function na(e){return jsxs(ee,{...e,children:[jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Ft(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function Vn(e){return jsx(ee,{...e,children:jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-8.5 8.5 9.5 9.5 0 0 1-3.5-.7L3 21l1.7-5.5A8.38 8.38 0 0 1 4 11.5 8.5 8.5 0 0 1 12.5 3 8.38 8.38 0 0 1 21 11.5Z"})})}function zn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M5 19 19 5"}),jsx("path",{d:"M11 5h8v8"})]})}function $n(e){return jsx(ee,{...e,children:jsx("rect",{x:"4",y:"6",width:"16",height:"12",rx:"2"})})}function Ut(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M5 19l1.5-5L16 4.5 19.5 8 10 17.5 5 19z"}),jsx("path",{d:"M14 6.5l3.5 3.5"})]})}function Wn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M9 8 4 13l5 5"}),jsx("path",{d:"M4 13h11a5 5 0 0 1 0 10h-1"})]})}function Vt(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),jsx("path",{d:"M21 4v4h-4"})]})}function Kn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M15 8 20 13l-5 5"}),jsx("path",{d:"M20 13H9a5 5 0 0 0 0 10h1"})]})}function qn(e){return jsxs(ee,{...e,children:[jsx("path",{d:"M4 7h16"}),jsx("path",{d:"M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"}),jsx("path",{d:"M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"})]})}function jn(e){return jsx(ee,{...e,strokeWidth:2.2,children:jsx("path",{d:"M15 6l-6 6 6 6"})})}function Yn(e){return jsx(ee,{...e,strokeWidth:1.9,children:jsx("path",{d:"M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z"})})}function it(e){return jsxs(ee,{...e,children:[jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsx("path",{d:"M8 21h8M12 17v4"})]})}function zt(e){return jsxs(ee,{...e,children:[jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var yt={shot:ta,video:na,upload:Ft};function Gn(e){let t=e.videoWidth||1280,n=e.videoHeight||720,r=document.createElement("canvas");r.width=t,r.height=n;let o=r.getContext("2d");return o?(o.drawImage(e,0,0,t,n),new Promise(a=>r.toBlob(i=>a(i),"image/jpeg",.82))):Promise.resolve(null)}function ra(e,t){return !Number.isFinite(t)||t<=0?Promise.resolve():new Promise(n=>{e.addEventListener("seeked",()=>n(),{once:true});try{e.currentTime=t;}catch{n();}})}var oa=4e3;async function $t(e){if(typeof document>"u")return {poster:null,durationMs:0};let t=URL.createObjectURL(e),n=document.createElement("video");n.muted=true,n.playsInline=true,n.preload="auto",n.src=t;let r=async()=>{await new Promise((d,c)=>{if(n.readyState>=2)return d();n.addEventListener("loadeddata",()=>d(),{once:true}),n.addEventListener("error",()=>c(new Error("video decode failed")),{once:true});}),await ra(n,Math.min(.1,(n.duration||0)/2));let i=await Gn(n),u=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:u}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),oa);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Wt(e){if(typeof document>"u")return null;let t=document.createElement("video");t.muted=true,t.playsInline=true,t.srcObject=e;try{return await t.play().catch(()=>{}),await new Promise(n=>{if(t.readyState>=2)return n();t.addEventListener("loadeddata",()=>n(),{once:!0}),window.setTimeout(n,600);}),await Gn(t)}catch{return null}finally{t.srcObject=null;}}async function Kt(){if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=1280,e.height=720;let t=e.getContext("2d");return t?(t.fillStyle="#0e0e12",t.fillRect(0,0,e.width,e.height),t.fillStyle="#52525b",t.beginPath(),t.moveTo(590,312),t.lineTo(590,408),t.lineTo(694,360),t.closePath(),t.fill(),new Promise(n=>e.toBlob(r=>n(r),"image/jpeg",.8))):null}var qt=60,aa=25*1024*1024,Zn=[{label:"Red",value:"rgb(239, 68, 68)"},{label:"Amber",value:"rgb(245, 158, 11)"},{label:"Blue",value:"rgb(59, 130, 246)"},{label:"Green",value:"rgb(34, 197, 94)"},{label:"Neutral",value:"rgb(244, 244, 245)"}],Xn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],ia=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],sa=[{value:"",label:"No priority"},{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],la=[{value:"web",label:"Web"},{value:"ios-web",label:"iOS web"},{value:"android-web",label:"Android web"},{value:"ios-native",label:"iOS native"},{value:"android-native",label:"Android native"}];function ua(e){if(e.platform==="ios")return "ios-native";if(e.platform==="android")return "android-native";if(e.platform==="custom")return "custom";let t=typeof navigator<"u"&&navigator.userAgent||"";return /android/i.test(t)?"android-web":/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&typeof document<"u"&&"ontouchend"in document?"ios-web":"web"}function ca({value:e}){return e==="urgent"?jsx("span",{className:"lumen-pri-ic lumen-pri-urgent","aria-hidden":"true",children:"!"}):jsxs("span",{className:"lumen-pri-ic lumen-pri-bars","data-level":e==="high"?3:e==="medium"?2:1,"aria-hidden":"true",children:[jsx("i",{}),jsx("i",{}),jsx("i",{})]})}var jt=[{value:"shot",label:"Screenshot",hint:"This page, instantly",primary:true},{value:"video",label:"Video",hint:"Record up to 60s"},{value:"upload",label:"Upload",hint:"Image or video"}];function Yt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:u,consumePendingVideo:d,canRecordScreen:c,consumeRecordStartError:m,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:v,keyboardInset:y}=nt(),[k,P]=useState(1),[S,T]=useState(null),[b,E]=useState({kind:"idle"}),[B,N]=useState(false),[F,A]=useState(0),[J,I]=useState("arrow"),[$,j]=useState(Zn[0].value),[W,se]=useState(Xn[1].value),[he,V]=useState(""),[He,_e]=useState("bug"),[be,xe]=useState(""),[ye,oe]=useState(""),[Ee,h]=useState(false),[w,x]=useState(false),[M,_]=useState(false),[K,ne]=useState(false),[re,Ce]=useState(r?.email??""),[z,ae]=useState(null),[q,Me]=useState(null),[Fe,Re]=useState(0),[ke,Se]=useState(null),[Ze,Pe]=useState(null),[lt,ut]=useState(false),[le,Te]=useState({canUndo:false,canRedo:false}),Y=useRef(null),We=useRef(null),ge=useRef(null),Le=useRef(null),Ke=useRef(null),Ne=ot(t,y),ve=useRef(false),qe=useRef(false);useEffect(()=>{t||(qe.current=false);},[t]),useEffect(()=>{if(!t)return;if(qe.current){ve.current=false;return}qe.current=true,ve.current=false,P(1),T(null),V(""),Me(null),Re(0),Se(null),N(false),A(0),oe(""),Pe(null),Te({canUndo:false,canRedo:false});let s=C();if(s){T("shot"),me(s),E({kind:"ready",capture:s});return}let g=d();if(g)T("video"),Se({blob:g.blob,durationMs:g.durationMs}),g.blob.size>aa&&toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),g.poster?E({kind:"ready",capture:Qe(g.poster,["Screen recording; preview is the first frame."])}):(E({kind:"capturing"}),(async()=>{let D=null;if(g.deriveBlobPoster)try{D=(await $t(g.blob)).poster;}catch{D=null;}D=D??await Kt(),!ve.current&&E(D?{kind:"ready",capture:Qe(D,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let D=m();D?(T("video"),Pe(D),E({kind:"idle"})):a?(T("shot"),E({kind:"ready",capture:a})):o?.mode==="manual"?E({kind:"manual"}):o?.provider&&!i?(T("shot"),Ue(o.mode??"auto")):E({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ve.current=true;}},[t,o,a,i]),useEffect(()=>{if(!t)return;Ke.current=document.activeElement??null;let s=document.documentElement,g=s.style.overflow,D=s.style.paddingRight,ie=window.innerWidth-s.clientWidth;s.style.overflow="hidden",ie>0&&(s.style.paddingRight=`${ie}px`);let ue=false,we=()=>{if(!ue){ue=true,s.style.overflow=g,s.style.paddingRight=D;try{Ke.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",we),()=>{window.removeEventListener("pagehide",we),we();}},[t]),useEffect(()=>{if(!t)return;function s(g){if(g.key==="Escape"){g.preventDefault(),n();return}if(g.key!=="Tab")return;let D=ge.current;if(!D)return;let ie=ya(D);if(ie.length===0)return;let ue=ie[0],we=ie[ie.length-1],xt=document.activeElement;g.shiftKey&&(xt===ue||!D.contains(xt))?(g.preventDefault(),we.focus()):!g.shiftKey&&xt===we&&(g.preventDefault(),ue.focus());}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),useEffect(()=>{if(!t||!v)return;let s=Le.current;if(!s)return;let g=D=>{D.target===s&&D.stopPropagation();};return s.addEventListener("pointerdown",g),s.addEventListener("click",g),s.addEventListener("touchstart",g,{passive:true}),()=>{s.removeEventListener("pointerdown",g),s.removeEventListener("click",g),s.removeEventListener("touchstart",g);}},[t,v]),useEffect(()=>{if(!t||!Ne.open)return;let s=ge.current,g=document.activeElement;if(s&&g&&s.contains(g))try{g.scrollIntoView({block:"center"});}catch{}},[t,Ne.open,Ne.inset]),useEffect(()=>{if(!t||b.kind!=="manual")return;function s(g){let ue=Array.from(g.clipboardData?.items??[]).find(we=>we.type.startsWith("image/"))?.getAsFile();ue&&(g.preventDefault(),Xe(ue));}return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[t,b.kind]),useEffect(()=>{if(!z)return;let s=Date.now(),g=window.setInterval(()=>{let D=Math.floor((Date.now()-s)/1e3);Re(D),D>=qt&&U();},250);return ()=>window.clearInterval(g)},[z]);let Ae=useRef(null);if(Ae.current=z,useEffect(()=>{t||Ae.current&&(Ae.current.cancel(),Ae.current=null,ae(null),Re(0));},[t]),useEffect(()=>()=>{Ae.current?.cancel();},[]),!t)return null;async function Ue(s){ve.current=false,E({kind:"capturing"});try{let g=await bt({...o,mode:s,target:o?.target??document.documentElement});return ve.current?!1:(me(g),E({kind:"ready",capture:g}),!0)}catch(g){return ve.current||E({kind:"manual",error:g instanceof Error?g.message:"Automatic screenshot capture was unavailable."}),false}}async function Ie(s){T(s),Pe(null),s!=="video"&&St(),s==="shot"?await Ue(o?.mode??"auto"):s==="video"?(Se(null),E({kind:"idle"})):(E({kind:"manual"}),We.current?.click());}async function Xe(s){if(s.type.startsWith("image/")){St();let g=Qe(s,["Manual image upload used."]);E({kind:"ready",capture:g});return}if(s.type.startsWith("video/")){E({kind:"capturing"});try{let{poster:g,durationMs:D}=await $t(s),ie=g??await Kt();if(!ie){E({kind:"manual",error:"Could not read that video."});return}let ue=Qe(ie,["Uploaded video; preview is the first frame."]);Se({blob:s,durationMs:D}),E({kind:"ready",capture:ue});}catch{E({kind:"manual",error:"Could not read that video."});}return}toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function me(s){s.warnings.length!==0&&toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function R(){try{let s=await An(qt);ae(s);}catch(s){toast.error(s instanceof Error?s.message:"Microphone unavailable");}}async function U(){if(z)try{let s=await z.stop();Me({blob:s.blob,durationMs:s.durationMs});}catch(s){toast.error(s instanceof Error?s.message:"Could not stop recording");}finally{ae(null);}}function G(){z?.cancel(),ae(null),Me(null),Re(0);}function ct(s){let g=jsxs("div",{className:"lumen-audio-row",children:[!z&&!q?jsxs("button",{type:"button",onClick:R,className:s==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsx(zt,{}),"Record voice note"]}):null,z?jsxs(Fragment,{children:[jsxs("span",{className:"lumen-recording",children:[jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsx(ha,{stream:z.stream}),jsxs("span",{className:"lumen-rec-time",children:[Fe,"s / ",qt,"s"]})]}),jsx("button",{type:"button",onClick:U,className:"lumen-btn-ghost",children:"Stop"}),jsx("button",{type:"button",onClick:G,className:"lumen-btn-ghost",children:"Cancel"})]}):null,q&&!z?jsxs(Fragment,{children:[jsx(ga,{blob:q.blob,durationMs:q.durationMs}),jsx("button",{type:"button",onClick:()=>Me(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return s==="capture"?jsxs("div",{className:"lumen-voice-capture",children:[g,!z&&!q?jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxs("div",{className:"lumen-label",children:[jsx("span",{children:"Add a voice note (optional)"}),g]})}async function Or(){Pe(null);try{await u();}catch(s){toast.error(s instanceof Error?s.message:"Screen capture unavailable");}}function St(){Se(null);}let Br=b.kind==="ready";async function Jt(){z&&await U(),k===1?(b.kind==="ready"&&!ye&&oe(ua(b.capture)),P(2)):await en();}function Qt(){k>1&&P(s=>s-1);}async function en(){if(b.kind!=="ready")return;let s=he.trim(),{capture:g}=b;N(true),A(0);try{let ie=await Y.current?.flatten()??g.blob,ue=await e.submit({rawText:s.length>0?s:void 0,category:He,priority:be||void 0,source:ye||void 0,submitterEmail:re.trim()||void 0,screenshot:ie,audio:q?.blob,audioDurationMs:q?.durationMs,video:ke?.blob,videoDurationMs:ke?.durationMs,context:Nn(g)},{onUploadProgress:we=>A(Math.min(.95,we))});A(1),toast.success("Feedback sent \u2014 thank you."),ue.id,n();}catch(D){toast.error(D instanceof Error?D.message:"Could not submit feedback"),N(false);}}function Hr(s){s.target===s.currentTarget&&!B&&n();}let je=Math.round(F*100),dt=S==="video",_r=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,tn=S==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&_r,nn=k===1&&!Br||B,Fr=k<3?"Next":B?je<95?`Uploading ${je}%\u2026`:"Almost done\u2026":"Send feedback",mt=k===1,rn=k===2&&b.kind==="ready",Ur=mt||rn;return jsx("div",{ref:Le,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Ne.inset?{"--lumen-keyboard-inset":`${Ne.inset}px`}:void 0,onMouseDown:Hr,children:jsxs("div",{ref:ge,className:"lumen-modal","data-lumen-drawing":lt?"true":void 0,"data-lumen-fs":Ur?"true":void 0,"data-lumen-review":rn?"true":void 0,"data-lumen-sheet":mt&&w?"down":void 0,children:[jsx(fa,{onDismiss:n}),jsxs("header",{className:"lumen-modal-header",children:[jsxs("h2",{className:"lumen-modal-title",children:[jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsx(da,{step:k}),jsx("input",{ref:We,type:"file",accept:"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime",style:{display:"none"},onChange:s=>{let g=s.currentTarget.files?.[0];g&&Xe(g),s.currentTarget.value="";}}),jsxs("div",{className:"lumen-modal-body",children:[k===1||k===2?jsx("div",{className:"lumen-pane",children:S===null?jsxs(Fragment,{children:[jsx("div",{className:"lumen-fs-top",children:jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})})}),jsxs("div",{className:"lumen-fs-center lumen-fs-picker",children:[jsxs("div",{className:"lumen-fs-picker-head",children:[jsx("div",{className:"lumen-fs-picker-title",children:"How do you want to capture?"}),jsx("div",{className:"lumen-fs-picker-sub",children:"Pick a method to report this."})]}),jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxs("button",{type:"button",className:"lumen-method-btn"+(s.primary?" lumen-method-primary":""),onClick:()=>Ie(s.value),disabled:b.kind==="capturing",children:[jsx("span",{className:"lumen-method-ico",children:jsx(g,{})}),s.primary?jsxs(Fragment,{children:[jsxs("span",{className:"lumen-method-text",children:[jsx("span",{className:"lumen-method-label",children:s.label}),jsx("span",{className:"lumen-method-hint",children:s.hint})]}),jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxs(Fragment,{children:[jsx("span",{className:"lumen-method-label",children:s.label}),jsx("span",{className:"lumen-method-hint",children:s.hint})]})]},s.value)})})]})]}):jsxs(Fragment,{children:[b.kind!=="ready"?jsxs(Fragment,{children:[jsxs("div",{className:"lumen-fs-top",children:[jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})}),jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsx("div",{className:"lumen-fs-pill",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>Ie(s.value),disabled:b.kind==="capturing",children:jsx(g,{})},s.value)})})})]}),jsxs("div",{className:"lumen-fs-center",children:[S==="video"&&b.kind==="idle"?jsx(ma,{canRecord:c,onRecord:Or,onUpload:()=>Ie("upload"),error:Ze}):null,b.kind==="capturing"?jsxs("p",{className:"lumen-status",children:[jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,b.kind==="manual"?jsxs("div",{className:"lumen-manual-capture",children:[jsx("p",{className:"lumen-status",children:S==="upload"?"Choose an image or video to attach \u2014 or paste an image.":b.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxs("label",{className:"lumen-manual-drop",children:[jsx("span",{children:S==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsx("input",{type:"file",accept:S==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:s=>{let g=s.currentTarget.files?.[0];g&&Xe(g),s.currentTarget.value="";}})]})]}):null]})]}):null,b.kind==="ready"?jsxs(Fragment,{children:[k===1?jsxs(Fragment,{children:[jsxs("div",{className:"lumen-fs-top",children:[jsxs("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:[jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"}),jsxs("div",{className:"lumen-fs-recap",children:[jsxs("button",{type:"button",className:"lumen-fs-chip",onClick:()=>_(s=>!s),"aria-haspopup":"menu","aria-expanded":M,children:[jsx(Vt,{})," Recapture",jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},"aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6"})})]}),M?jsxs(Fragment,{children:[jsx("div",{className:"lumen-fs-recap-overlay",onClick:()=>_(false)}),jsxs("div",{className:"lumen-fs-recap-menu",role:"menu",children:[jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),S&&Ie(S);},children:[jsx("span",{className:"lumen-fs-mi-ic",children:jsx(Vt,{})}),jsxs("span",{children:[jsx("b",{children:"Re-snap this view"}),jsx("small",{children:"Instant \xB7 masks sensitive fields"})]})]}),tn?jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),p();},children:[jsx("span",{className:"lumen-fs-mi-ic",children:jsx(it,{})}),jsxs("span",{children:[jsx("b",{children:"Capture exact pixels"}),jsx("small",{children:"Real screen \u2014 canvas, video & charts"})]})]}):null]})]}):null]})]}),jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxs("div",{className:"lumen-fs-pill",role:"group","aria-label":"Tools and capture method",children:[dt?null:jsxs(Fragment,{children:[jsx("button",{type:"button",className:"lumen-fs-pill-btn lumen-fs-pentog","data-on":!Ee,onClick:()=>h(s=>!s),"aria-label":"Toggle markup tools",title:"Toggle markup tools",children:jsx(Ut,{})}),jsx("span",{className:"lumen-fs-pill-sep"})]}),jt.map(s=>{let g=yt[s.value];return jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>Ie(s.value),children:jsx(g,{})},s.value)})]})})]}),!dt&&!Ee?jsxs("div",{className:"lumen-toolbar",children:[jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsx(Et,{label:"Arrow",icon:jsx(zn,{}),active:J==="arrow",onClick:()=>I("arrow")}),jsx(Et,{label:"Box",icon:jsx($n,{}),active:J==="rect",onClick:()=>I("rect")}),jsx(Et,{label:"Draw",icon:jsx(Ut,{}),active:J==="freehand",onClick:()=>I("freehand")}),jsx(Et,{label:"Comment",icon:jsx(Vn,{}),active:J==="comment",onClick:()=>I("comment")})]}),jsx("span",{className:"lumen-toolbar-sep"}),jsxs("div",{className:"lumen-fs-color",children:[jsx("button",{type:"button",className:"lumen-fs-color-btn",style:{background:$},"aria-label":"Pick colour","aria-haspopup":"true","aria-expanded":K,onClick:()=>ne(s=>!s)}),K?jsxs(Fragment,{children:[jsx("div",{className:"lumen-fs-color-overlay",onClick:()=>ne(false)}),jsx("div",{className:"lumen-fs-color-pop",role:"group","aria-label":"Colour",children:Zn.map(s=>jsx("button",{type:"button",className:"lumen-swatch",style:{background:s.value},"aria-label":s.label,"aria-pressed":$===s.value,onClick:()=>{j(s.value),ne(false);}},s.value))})]}):null]}),mt?null:jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Xn.map(s=>jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":s.label,"aria-pressed":W===s.value,onClick:()=>se(s.value),children:jsx("span",{className:"lumen-stroke-size-dot",style:{width:s.dot,height:s.dot}})},s.value))}),mt?null:jsx("span",{className:"lumen-toolbar-spacer"}),jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.undo(),disabled:!le.canUndo,"aria-label":"Undo",title:"Undo",children:jsx(Wn,{})}),jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.redo(),disabled:!le.canRedo,"aria-label":"Redo",title:"Redo",children:jsx(Kn,{})}),jsx("button",{type:"button",className:"lumen-tool",onClick:()=>Y.current?.reset(),disabled:!le.canUndo,"aria-label":"Clear",title:"Clear",children:jsx(qn,{})})]}):null]}):null,jsx("div",{className:"lumen-annotate",children:jsx(Fn,{ref:Y,screenshot:b.capture.blob,tool:J,color:$,strokeWidth:W,onDrawingChange:ut,onHistoryChange:Te})}),k===1?jsxs(Fragment,{children:[jsxs("div",{className:"lumen-cap-actions",children:[jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>S&&Ie(S),children:dt?"\u21BB Re-record":"\u21BB Recapture"}),tn?jsxs("button",{type:"button",className:"lumen-btn-ghost lumen-exact-btn",onClick:()=>{p();},title:"Capture the real screen pixels \u2014 your browser will ask which tab or window to share, then you arrange the page and press Capture.",children:[jsx(it,{})," Capture exact screen"]}):null,dt?ke?jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ke.durationMs/1e3),"s recorded"]}):null:jsx("span",{className:"lumen-cap-note",children:b.capture.method==="web-display-media"?"Exact screen captured":`${Jn(S)} captured \xB7 switch method above anytime`})]}),jsxs("div",{className:"lumen-fs-compose",children:[jsx("button",{type:"button",className:"lumen-fs-grab",onClick:()=>x(s=>!s),"aria-label":w?"Expand sheet":"Minimize sheet"}),jsxs("div",{className:"lumen-fs-field",children:[jsx("input",{className:"lumen-input lumen-fs-desc",value:he,onChange:s=>V(s.target.value),placeholder:"Describe what's wrong \u2014 or use voice"}),jsx("button",{type:"button",className:"lumen-fs-mic",onClick:R,"aria-label":"Record voice note",children:jsx(zt,{})})]}),ct("capture"),jsx("button",{type:"button",className:"lumen-btn-primary lumen-fs-next",onClick:Jt,disabled:nn,children:"Next"})]})]}):null]}):null]})}):null,k===2?jsxs("div",{className:"lumen-pane lumen-rv-pane",children:[jsx("div",{className:"lumen-rv-scrim","aria-hidden":"true"}),jsxs("div",{className:"lumen-rv",children:[jsxs("div",{className:"lumen-rv-head",children:[jsxs("button",{type:"button",className:"lumen-rv-back",onClick:Qt,children:[jsx(jn,{}),"Back"]}),jsx("span",{className:"lumen-rv-title",children:"Review & send"}),jsx("span",{className:"lumen-rv-spacer","aria-hidden":"true"})]}),jsxs("div",{className:"lumen-rv-rows",children:[jsxs("div",{className:"lumen-rv-set",children:[jsxs("span",{className:"lumen-rv-k",children:["Description"," ",jsx("span",{className:"lumen-rv-muted",children:"\xB7 tap to edit"})]}),jsx("textarea",{className:"lumen-input lumen-rv-desc",value:he,onChange:s=>V(s.target.value),rows:2,placeholder:"Describe what's wrong\u2026"})]}),jsxs("div",{className:"lumen-rv-set",children:[jsx("span",{className:"lumen-rv-k",children:"Type"}),jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Type",children:ia.map(s=>jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":He===s.value,onClick:()=>_e(s.value),children:s.label},s.value))})]}),jsxs("div",{className:"lumen-rv-set",children:[jsx("span",{className:"lumen-rv-k",children:"Priority"}),jsx("div",{className:"lumen-rv-prio",role:"group","aria-label":"Priority",children:sa.filter(s=>s.value!=="").map(s=>jsxs("button",{type:"button",className:"lumen-rv-prio-opt","aria-pressed":be===s.value,onClick:()=>xe(be===s.value?"":s.value),children:[jsx(ca,{value:s.value}),s.label]},s.value))})]}),jsxs("div",{className:"lumen-rv-set",children:[jsxs("span",{className:"lumen-rv-k",children:["Platform"," ",jsx("span",{className:"lumen-rv-muted",children:"\xB7 auto-detected \u2014 change if wrong"})]}),jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Platform",children:la.map(s=>jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":ye===s.value,onClick:()=>oe(s.value),children:s.label},s.value))})]}),jsxs("div",{className:"lumen-rv-row",children:[jsx("span",{className:"lumen-rv-rk",children:"Capture"}),jsxs("span",{className:"lumen-rv-rv",children:[Jn(S),le.canUndo?" \xB7 annotated":"",jsx("button",{type:"button",className:"lumen-edit",onClick:()=>P(1),children:"edit"})]})]}),ct("describe"),jsx("div",{className:"lumen-rv-attachrow",children:ke?jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ke.durationMs/1e3),"s",jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:St,children:"\xD7"})]}):jsxs("label",{className:"lumen-rv-attach",children:[jsx(Ft,{}),"Attach a video",jsx("input",{type:"file",accept:"video/mp4,video/webm,video/quicktime",onChange:s=>{let g=s.currentTarget.files?.[0];g&&Se({blob:g,durationMs:0}),s.currentTarget.value="";}})]})})]}),jsx("button",{type:"button",className:"lumen-btn-primary lumen-rv-send",onClick:en,disabled:B,children:B?je<95?`Uploading ${je}%\u2026`:"Almost done\u2026":jsxs(Fragment,{children:[jsx(Yn,{}),"Send feedback"]})})]})]}):null]}),jsxs("footer",{className:"lumen-modal-footer",children:[B?jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":je,children:jsx("div",{className:"lumen-progress-fill",style:{width:`${je}%`}})}):null,jsxs("div",{className:"lumen-modal-actions",children:[jsx("button",{type:"button",onClick:k===1?n:Qt,className:"lumen-btn-ghost",disabled:B,children:k===1?"Cancel":"Back"}),jsx("button",{type:"button",onClick:Jt,className:"lumen-btn-primary",disabled:nn,children:Fr})]})]})]})})}function Jn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function da({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsx("span",{className:"lumen-step-num",children:n.n}),jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function ma({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxs("div",{className:"lumen-record-prompt",children:[r?jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxs("div",{className:"lumen-record-copy",children:[jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsx("div",{className:"lumen-record-sub",children:"Tap to start. The sheet closes so you can record freely \u2014 a Stop button stays on screen, then the sheet returns with your clip. Max 60s."})]})]}):jsxs("div",{className:"lumen-record-prompt",children:[jsx("p",{className:"lumen-record-unavailable",children:pa()?jsx(Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsx(Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function pa(){if(typeof navigator>"u")return false;let e=navigator.userAgent||"";return /iPad|iPhone|iPod/.test(e)?true:/Macintosh/.test(e)&&typeof document<"u"&&"ontouchend"in document}function Et({label:e,active:t,onClick:n,icon:r}){return jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,"aria-label":r?e:void 0,title:e,children:r??e})}function fa({onDismiss:e}){let t=useRef(null),n=useRef(0),r=useRef(null);function o(u){u.currentTarget.setPointerCapture(u.pointerId),t.current=u.clientY,n.current=performance.now(),r.current=u.currentTarget.parentElement;}function a(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current);r.current.style.transform=`translateY(${d}px)`;}function i(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current),c=Math.max(1,performance.now()-n.current),m=d/c;r.current.style.transform="",r.current.style.transition="",t.current=null,(d>80||m>.6)&&e();}return jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function ha({stream:e}){let t=useRef(null);return useEffect(()=>{let n=t.current;if(!n)return;let r=Math.min(window.devicePixelRatio||1,2),o=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(o*r),n.height=Math.round(a*r);let i=n.getContext("2d");if(!i)return;i.scale(r,r);let u=window.AudioContext??window.webkitAudioContext;if(!u)return;let d=new u,c=d.createMediaStreamSource(e),m=d.createAnalyser();m.fftSize=1024,m.smoothingTimeConstant=.6,c.connect(m);let p=new Uint8Array(m.fftSize),C=18,v=3,y=3,k=Math.max(2,(o-v*(C-1))/C),P=Math.min(k/2,3),S=new Array(C).fill(0),T=0,b=false;function E(){if(b)return;m.getByteTimeDomainData(p);let B=Math.floor(p.length/C);i.clearRect(0,0,o,a),i.fillStyle=va("--lumen-danger")||"rgb(239,68,68)";for(let N=0;N<C;N++){let F=0;for(let W=0;W<B;W++){let se=Math.abs((p[N*B+W]??128)-128);se>F&&(F=se);}let A=Math.min(1,F/128*1.8),J=S[N]??0;S[N]=A>J?A:J+(A-J)*.35;let I=Math.max(y,S[N]*a),$=N*(k+v),j=(a-I)/2;ba(i,$,j,k,I,P),i.fill();}T=requestAnimationFrame(E);}return T=requestAnimationFrame(E),()=>{b=true,cancelAnimationFrame(T);try{c.disconnect();}catch{}d.close();}},[e]),jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function ba(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function ga({blob:e,durationMs:t}){let[n,r]=useState("");return useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxs("div",{className:"lumen-audio-preview",children:[jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function va(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var wa='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function ya(e){return Array.from(e.querySelectorAll(wa)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var Ct=class extends _n.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t,n){if(typeof document<"u"){let r=document.documentElement;r.style.overflow="",r.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),toast.error("Feedback widget hit a snag and was reset. Please try again.");try{let r=t instanceof Error?t:null;this.props.onError?.({message:r?.message??String(t),name:r?.name??"Error",stack:r?.stack,componentStack:n?.componentStack??void 0});}catch{}Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function rr({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=useState(false);if(useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?createPortal(jsx(Ca,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):createPortal(jsxs("div",{className:"lumen-rec-hud lumen-rec-hud-pending",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function Ca({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=useState(0);useEffect(()=>{let u=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));u();let d=window.setInterval(u,250);return ()=>window.clearInterval(d)},[e,t]);let i=u=>`${Math.floor(u/60)}:${String(u%60).padStart(2,"0")}`;return jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function or({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=useState(false);if(useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,u=e.phase==="grabbing";return createPortal(jsxs("div",{className:"lumen-cap-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[u?jsx("span",{className:"lumen-cap-hud-spinner","aria-hidden":"true"}):jsx("span",{className:"lumen-cap-hud-ico","aria-hidden":"true",children:jsx(it,{})}),jsx("span",{className:"lumen-cap-hud-text",children:u?"Capturing\u2026":"Arrange the screen, then capture"}),jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:u,children:"Cancel"}),jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:u,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Gt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function ar(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function ir(e){return e instanceof Error?e:new Error(String(e))}function sr(e,t,n){let r=false,o=false,a=false,i=null;function u(){o||(o=true,n.onCancelled());}function d(m){o||(o=true,n.onResult(m));}function c(m){o||(o=true,n.onError(m));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(m=>{if(i=m,r){try{m.cancel();}catch{}u();return}if(n.onActive(m),a){n.onProcessing();try{m.stop();}catch{}}Promise.resolve(m.result).then(p=>{r?u():d(p);}).catch(p=>{r||ar(p)?u():c(ir(p));});}).catch(m=>{r||ar(m)?u():c(ir(m));}),{stop(){if(!(o||r||a)&&(a=true,i)){n.onProcessing();try{i.stop();}catch{}}},cancel(){if(!(o&&r)){if(r=true,i)try{i.cancel();}catch{}u();}}}}function lr(){if(typeof document>"u"||typeof window>"u")return 0;let e=window.innerWidth,t=window.innerHeight;if(e===0||t===0)return 0;let n=t-4,r=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],o=new Set,a=0;for(let i of r){let u=document.elementsFromPoint(i,n);for(let d of u){if(o.has(d))continue;o.add(d);let c=window.getComputedStyle(d);if(c.position!=="fixed"&&c.position!=="sticky")continue;let m=d.getBoundingClientRect();m.bottom<t-8||m.bottom>t+8||m.width<e*.6||m.height>a&&(a=m.height);}}return a}function Zt(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,r=window.innerHeight,o=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let u of Array.from(i)){let d=u.getBoundingClientRect();if(d.height===0||d.width===0)continue;let c=0;switch(t){case "bottom":if(d.bottom<r-8)break;c=Math.max(0,r-d.top);break;case "top":if(d.top>8)break;c=Math.max(0,d.bottom);break;case "left":if(d.left>8)break;c=Math.max(0,d.right);break;case "right":if(d.right<n-8)break;c=Math.max(0,n-d.left);break}c>o&&(o=c);}}return o}function ur(e){let[t,n]=useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=useRef(t),o=La(e.avoid),a=e.placement,i=e.offset.x,u=e.offset.y;return useEffect(()=>{if(typeof window>"u")return;let d=0,c=false,m=()=>{if(d=0,c)return;let k=a[0]==="b"?"bottom":"top",P=a[1]==="r"?"right":"left",S=0,T=0;e.avoid==="auto"&&k==="bottom"?S=lr():Array.isArray(e.avoid)&&(S=Zt(e.avoid,k),T=Zt(e.avoid,P));let b={bottom:k==="bottom"?u+S:0,top:k==="top"?u+S:0,right:P==="right"?i+T:0,left:P==="left"?i+T:0},E=r.current;(b.bottom!==E.bottom||b.top!==E.top||b.right!==E.right||b.left!==E.left)&&(r.current=b,n(b));},p=()=>{d||(d=window.requestAnimationFrame(m));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let v=typeof MutationObserver<"u"?new MutationObserver(p):null;v?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let y=window.visualViewport;return y?.addEventListener("resize",p),y?.addEventListener("scroll",p),()=>{c=true,d&&window.cancelAnimationFrame(d),C?.disconnect(),v?.disconnect(),window.removeEventListener("resize",p),y?.removeEventListener("resize",p),y?.removeEventListener("scroll",p);}},[a,i,u,o]),t}function La(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var cr=["mousedown","touchstart"];function Ge(e){let t=useRef(e.onPointerDown);t.current=e.onPointerDown;let n=useRef(e.onClick);n.current=e.onClick;let r=useRef(e.isolate??true);r.current=e.isolate??true;let o=useRef(null);return useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=c=>{r.current&&c.stopPropagation(),t.current?.(c);},u=c=>{r.current&&c.stopPropagation(),n.current(c);},d=c=>{r.current&&c.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",u);for(let c of cr)a.addEventListener(c,d,c==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",u);for(let c of cr)a.removeEventListener(c,d);};},[])}function fr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[u,d]=useState(null),c=useRef(null),m=ur(e),p=ot(e.keyboard!=="off",i),C=Ge({onPointerDown:r,onClick:o,isolate:a}),v=useCallback(A=>{c.current=A,C(A);},[C]);useEffect(()=>{typeof document>"u"||d(t??document.body);},[t]);let y=e.placement,k=y[0]==="b"?"bottom":"top",P=y[1]==="r"?"right":"left",S=k==="bottom",T=p.open&&S&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,b=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&S&&p.inset<=0);if(Oa(c,!n&&!b),!u)return null;let E=k==="bottom"?m.bottom:m.top,B=P==="right"?m.right:m.left,N=n||b,F={position:"fixed",[k]:e.safeArea?`calc(${E}px + env(safe-area-inset-${k}, 0px))`:`${E}px`,[P]:e.safeArea?`calc(${B}px + env(safe-area-inset-${P}, 0px))`:`${B}px`,zIndex:e.zIndex,transform:T?`translateY(-${T}px)`:void 0,opacity:N?0:1,pointerEvents:N?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return createPortal(jsxs("button",{ref:v,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:F,"aria-label":e.label,"aria-hidden":N?true:void 0,tabIndex:N?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsx("span",{children:e.label})]}),u)}function Oa(e,t){let n=useRef(false);useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let r=window.setTimeout(()=>{let o=e.current;if(!o)return;let a=o.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,u=a.top+a.height/2,d=document.elementsFromPoint(i,u),c=dr(window.getComputedStyle(o).zIndex);for(let m of d){if(m===o||o.contains(m))continue;if(dr(window.getComputedStyle(m).zIndex)>c){n.current=true,console.warn("[lumen] trigger is occluded by",m);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function dr(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function hr({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=useState(null),d=Ge({onPointerDown:r,onClick:o,isolate:a});return useEffect(()=>{if(typeof document>"u")return;let c=e instanceof HTMLElement?e:e.current??null;u(c);},[e]),i?createPortal(jsxs("button",{ref:d,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsx("span",{children:t})]}),i):null}function vr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=useState(null),[d,c]=useState(false),m=useRef(null),p=Ge({onPointerDown:P=>{r?.(P),m.current={x:P.clientX,y:P.clientY},c(true);let S=P.currentTarget;try{S?.setPointerCapture?.(P.pointerId);}catch{}},onClick:o,isolate:a});if(useEffect(()=>{typeof document>"u"||u(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${d?" lumen-notch-expanded":""}`;function v(P){let S=m.current;if(!S)return;let T=P.clientX-S.x,b=P.clientY-S.y;(e.edge==="top"&&b>16||e.edge==="bottom"&&b<-16||e.edge==="right"&&T<-16||e.edge==="left"&&T>16)&&(m.current=null,o(P.nativeEvent));}function y(){m.current=null,c(false);}function k(){m.current=null,c(false);}return createPortal(jsxs("button",{ref:p,type:"button",className:C,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:v,onPointerUp:y,onPointerCancel:k,onMouseEnter:()=>c(true),onMouseLeave:()=>c(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function wr(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function ja(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function yr(e){return {kind:"floating",placement:e.placement??"br",offset:{x:e.offset?.x??16,y:e.offset?.y??16},safeArea:e.safeArea??true,avoid:e.avoid===false?false:e.avoid==null?"auto":Array.isArray(e.avoid)?e.avoid:[e.avoid],keyboard:ja(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Za={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function Er(e){let t=useId();useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${Xa(t)}`,o={},a=(i,u)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,u);};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else {for(let[i,u]of Object.entries(Za)){let d=e[u];typeof d=="string"&&d.length>0&&a(i,d);}typeof e.accent=="string"&&e.accent.length>0&&(a("--lumen-accent",e.accent),a("--lumen-primary",e.accent),a("--lumen-accent-fg","#ffffff")),(e.scheme==="light"||e.scheme==="dark")&&(o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e.scheme));}return n.setAttribute(r,""),()=>{n.removeAttribute(r);for(let[i,u]of Object.entries(o))i.startsWith("--")?u?n.style.setProperty(i,u):n.style.removeProperty(i):u==null?n.removeAttribute(i):n.setAttribute(i,u);}},[e,t]);}function Xa(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Cr=Symbol.for("lumen.history.patched"),Xt="lumen:locationchange";function ei(){if(typeof window>"u")return;let e=window;if(e[Cr])return;e[Cr]=true;let t=()=>window.dispatchEvent(new Event(Xt)),n=history.pushState;history.pushState=function(...o){let a=n.apply(this,o);return t(),a};let r=history.replaceState;history.replaceState=function(...o){let a=r.apply(this,o);return t(),a},window.addEventListener("popstate",t);}function Rr(e){let[t,n]=useState(false);return useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;ei();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Xt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Xt,r),window.removeEventListener("popstate",r);}},[e]),t}var ri=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function kr(){let[e,t]=useState(false);return useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let r=n.webkit;if(r&&r.messageHandlers){t(true);return}let o=navigator.userAgent||"";ri.some(a=>o.includes(a))&&t(true);},[]),e}var xr="lumen.config.v1.",ii=3600*1e3;function Mr(e,t){let[n,r]=useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return useEffect(()=>{if(typeof window>"u")return;let o=mi(e);o&&r({trigger:o.trigger,enabled:Sr(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),u=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(u,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.json(),m=Pr(c.trigger);if(!m)throw new Error("Malformed config response");let p=ui(c.trigger),C=Tr(c.brand);pi(e,m,p,C),r({trigger:m,enabled:Sr(m),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(d=>d.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:d);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Sr(e){return e.kind!=="headless"}var si=["br","bl","tr","tl"],li=["top","right","bottom","left"];function Pr(e){if(!e||typeof e!="object")return null;let t=e;if(t.enabled===false)return {kind:"headless"};let n=typeof t.label=="string"?t.label:"Feedback";return t.kind==="floating"?{kind:"floating",placement:si.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:li.find(o=>o===t.edge)??"top",label:n}:null}function ui(e){return !e||typeof e!="object"?false:e.shake===true}var ci=/^#[0-9a-fA-F]{6}$/,di=["auto","light","dark"];function Tr(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&ci.test(t.accent)?t.accent:null;if(!n)return null;let r=di.find(a=>a===t.mode)??"auto",o=typeof t.radius=="number"&&Number.isFinite(t.radius)?Math.min(20,Math.max(0,Math.round(t.radius))):10;return {accent:n,mode:r,radius:o}}function mi(e){try{let t=window.localStorage.getItem(xr+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>ii)return null;let r=Pr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:Tr(n.brand)}:null}catch{return null}}function pi(e,t,n,r){try{window.localStorage.setItem(xr+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function hi(e){if(e&&typeof e=="object")return e.type===vt;if(typeof e=="string")try{return JSON.parse(e).type===vt}catch{return false}return false}function bi(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(u,d,c,m){if(!a)return a={x:u,y:d,z:c,t:m},false;if(m-a.t<o)return false;let p=Math.abs(u-a.x)+Math.abs(d-a.y)+Math.abs(c-a.z);return a={x:u,y:d,z:c,t:m},p<t?false:(i=i.filter(C=>m-C<r),i.push(m),i.length>=n?(i=[],true):false)}}}function Lr(e,t,n){useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let m=Date.now();n||m-r<o||(r=m,t());}let i=m=>{hi(m.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let u=bi(),d=m=>{let p=m.accelerationIncludingGravity??m.acceleration;!p||p.x==null||p.y==null||p.z==null||u.push(p.x,p.y,p.z,Date.now())&&a();},c=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return c&&window.addEventListener("devicemotion",d),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),c&&window.removeEventListener("devicemotion",d);}},[e,t,n]);}var Ar="https://shakebugs.vercel.app",kt=60;function Ir(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function wi({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:u,portalTarget:d,capture:c,record:m,shakeToOpen:p,onOpenChange:C,beforeOpen:v,onTriggerActivate:y,isolateEvents:k=true,keyboardInset:P,suppressTrigger:S=false,children:T}){let[b,E]=useState(false),[B,N]=useState(false),[F,A]=useState(null),[J,I]=useState(null),[$]=useState(false),[j]=useState(null),W=useRef(false),se=useRef(false),he=useRef(null),V=useMemo(()=>new gn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);useEffect(()=>{Tn({ignoreUrlPrefix:(t??Ar).replace(/\/$/,"")});},[t]);let He=useRef(C);He.current=C,useEffect(()=>{if(!(typeof document>"u"))return b?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[b]);let _e=useRef(null);useEffect(()=>{if(_e.current===b)return;let R=_e.current;_e.current=b,R!==null&&He.current?.(b);},[b]);let be=useRef(v);be.current=v;let xe=useRef(y);xe.current=y;let ye=useCallback(R=>{se.current=true,he.current=Promise.resolve().then(()=>be.current?.(R)).then(()=>xe.current?.(R)).then(()=>{});},[]),oe=useCallback(R=>{W.current||b||ae.current||ge.current||(W.current=true,N(true),A(null),I(null),(async()=>{try{if(se.current?await he.current:(await be.current?.(R),await xe.current?.(R)),c?.mode==="manual")A(null),I(null);else if(c?.provider)A(null),I(null);else {let U=await bt({...c,mode:c?.mode??"auto",target:c?.target??document.documentElement});A(U);}}catch(U){I(U instanceof Error?U:new Error(String(U)));}finally{se.current=false,he.current=null,W.current=false,N(false),E(true);}})());},[c,b]),Ee=useCallback(()=>{E(false),A(null),I(null);},[]),h=useCallback(V.submit.bind(V),[V]),[w,x]=useState(0),M=useCallback(()=>{W.current=false,N(false),E(false),A(null),I(null),x(R=>R+1);},[]),[_,K]=useState(null),[ne,re]=useState(null),Ce=useRef(null),z=useRef(null),ae=useRef(false),q=useRef(null),Me=useRef(null),Fe=useRef(null),Re=useCallback((R,U=false)=>{if(Ce.current=null,z.current=null,ae.current=false,K(null),!R){q.current=null;return}Me.current={blob:R.blob,durationMs:R.durationMs,poster:q.current,deriveBlobPoster:U},q.current=null,E(true);},[]);useEffect(()=>{if(!b)return;if(!m?.provider){re(null);return}let R=m.isAvailable;if(!R){re(true);return}let U=false;return Promise.resolve().then(()=>R()).then(G=>{U||re(G);}).catch(()=>{U||re(false);}),()=>{U=true;}},[b,m?.provider,m?.isAvailable]);let ke=Gt({hasProvider:!!m?.provider,providerAvailable:ne,hasGetDisplayMedia:Ir()}).canRecord,Se=useCallback(async()=>{if(ae.current)return;if(Fe.current=null,Gt({hasProvider:!!m?.provider,providerAvailable:ne,hasGetDisplayMedia:Ir()}).usingProvider&&m?.provider){ae.current=true,q.current=null,E(false),z.current=sr(m.provider,{maxDurationSeconds:kt},{onStarting:()=>K({phase:"starting"}),onActive:G=>{K({phase:"recording",stream:G.stream??null,startedAt:Date.now(),maxSeconds:kt}),G.stream&&Wt(G.stream).then(ct=>{q.current=ct;}).catch(()=>{});},onProcessing:()=>K({phase:"processing"}),onResult:G=>Re({blob:G.blob,durationMs:G.durationMs},true),onCancelled:()=>{z.current=null,ae.current=false,q.current=null,K(null),A(null),I(null),E(true);},onError:G=>{z.current=null,ae.current=false,q.current=null,K(null),Fe.current=G.message||"Screen recording could not start.",E(true);}});return}if(Ce.current)return;let U=await In(kt);Ce.current=U,ae.current=true,q.current=null,K({phase:"recording",stream:U.stream,startedAt:Date.now(),maxSeconds:kt}),E(false),Wt(U.stream).then(G=>{q.current=G;}).catch(()=>{}),U.result.then(G=>Re(G)).catch(()=>Re(null));},[Re,m?.provider,ne]),Ze=useCallback(()=>{z.current?z.current.stop():Ce.current?.stop();},[]),Pe=useCallback(()=>{if(z.current){z.current.cancel();return}let R=Ce.current;Ce.current=null,ae.current=false,q.current=null,K(null),R?.cancel(),A(null),I(null),E(true);},[]),lt=useCallback(()=>{let R=Me.current;return Me.current=null,R},[]),ut=useCallback(()=>{let R=Fe.current;return Fe.current=null,R},[]);useEffect(()=>{b||(Fe.current=null);},[b]);let[le,Te]=useState(null),Y=useRef(null),We=useRef(null),ge=useRef(false),Le=useCallback(()=>{let R=Y.current;Y.current=null,ge.current=false,R?.stop(),Te(null),E(true);},[]),Ke=useCallback(()=>{let R=Y.current;R&&(Te({phase:"grabbing"}),(async()=>{try{let U=await R.grab();if(Y.current!==R)return;We.current=U,Y.current=null,ge.current=!1,R.stop(),Te(null),E(!0);}catch{if(Y.current!==R)return;Y.current=null,ge.current=false,R.stop(),Te(null),toast.error("Could not capture the screen. Please try again."),E(true);}})());},[]),Ne=useCallback(async()=>{if(ge.current)return;let R;try{R=await Nt({...c});}catch{return}Y.current=R,ge.current=true,R.onEnded(()=>Le()),Te({phase:"live"}),E(false);},[c,Le]),ve=useCallback(()=>{let R=We.current;return We.current=null,R},[]);useEffect(()=>()=>{Y.current?.stop(),Y.current=null;},[]);let qe=kr(),Ae=Rr(i),Ue=Mr(a?"":e,t??Ar);Er(u??Ci(Ue.brand));let Ie=p??Ue.shakeToOpen;Lr(Ie,oe,b);let Xe=useMemo(()=>({client:V,user:n,isOpen:b,isSubmitting:$,error:j,open:oe,close:Ee,openCapture:oe,closeCapture:Ee,submit:h,isNativeShell:qe,capture:c,initialCapture:F,initialCaptureError:J,isOpening:B,startVideoSession:Se,stopVideoSession:Ze,cancelVideoSession:Pe,recording:_,consumePendingVideo:lt,canRecordScreen:ke,consumeRecordStartError:ut,startScreenCaptureSession:Ne,grabScreenCaptureFrame:Ke,cancelScreenCaptureSession:Le,screenCapture:le,consumePendingScreenshot:ve,isolateEvents:k,keyboardInset:P}),[V,n,b,$,j,oe,Ee,h,qe,c,F,J,Se,Ze,Pe,_,lt,ke,ut,Ne,Ke,Le,le,ve,B,k,P]),me=Ei({explicit:a,remote:Ue.trigger,remoteLoading:Ue.loading,floatingButton:o});return jsxs(Ot.Provider,{value:Xe,children:[T,jsxs(Ct,{onReset:M,onError:R=>V.reportClientError({...R,context:{open:b,opening:B,screenCapturePhase:le?.phase,recordingPhase:_?.phase,initialCaptureMethod:F?.method,initialCapturePixelRatio:F?.pixelRatio,initialCaptureViewport:F?.viewport,hadInitialCaptureError:J!=null}}),children:[me?.kind==="floating"?jsx(fr,{config:yr(me),portalTarget:d,hidden:Ae||S||B||_!=null||le!=null,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k,keyboardInset:P}):null,me?.kind==="notch"?jsx(vr,{config:wr(me),portalTarget:d,hidden:Ae||S||B||_!=null||le!=null,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k}):null,me?.kind==="inline"?jsx(hr,{mount:me.mount,label:me.label??"Feedback",icon:me.icon,onPointerDown:ye,onClick:R=>oe(R),isolateEvents:k}):null,le?jsx(or,{state:le,portalTarget:d,onCapture:Ke,onCancel:Le}):null,_?jsx(rr,{state:_,portalTarget:d,onStop:Ze,onCancel:Pe}):null,jsx(Yt,{})]},w),jsx(yi,{})]})}function yi(){let[e,t]=useState(false);return useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsx(Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Ei(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Ci(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Ri({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=nt(),u=["lumen-btn",e==="default"?"lumen-btn-primary":null,e==="ghost"?"lumen-btn-ghost":null,e==="outline"?"lumen-btn-outline":null,t?"lumen-btn-floating":null,n].filter(Boolean).join(" ");return jsx("button",{type:"button",className:u,"data-lumen-trigger":"",onClick:d=>{o?.(d),d.defaultPrevented||i(d.nativeEvent);},...a,children:r})}
5
5
  export{Yt as CaptureModal,Ri as FeedbackButton,It as LUMEN_KEYBOARD_CSS_VAR,tt as LUMEN_KEYBOARD_EVENT,vt as LUMEN_SHAKE_MESSAGE,wi as LumenProvider,Io as createNativeCaptureProvider,Po as isLumenEventTarget,To as isolateLumenEvents,Dt as readLumenKeyboardInset,zo as setLumenKeyboardInset,ot as useKeyboardInset,nt as useLumen};//# sourceMappingURL=index.js.map
6
6
  //# sourceMappingURL=index.js.map