@lumen-stack/react 0.11.0 → 0.12.1

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.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- 'use strict';var dn=require('react'),sonner=require('sonner'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var dn__namespace=/*#__PURE__*/_interopNamespace(dn);var A=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},At=class extends A{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},Nt=class extends A{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},Xe=class extends A{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},cr="https://shakebugs.vercel.app",dr="/api/v1/sdk/submit",mr=new Set([502,503,504]),$t=class{apiKey;apiUrl;user;amplitude;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new A("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??cr).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${dr}`,r=this.#e(e),o=null;for(let a=0;a<3;a++){a>0&&await fr(2**a*250);try{return await this.#t(n,r,t)}catch(i){if(o=i,i instanceof At||i instanceof Nt||i instanceof A&&typeof i.status=="number"&&!mr.has(i.status))throw i}}throw o instanceof Error?o:new Xe("Submit failed after 3 attempts.")}#e(e){let t=new FormData;e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),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,pr(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}#t(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:l}=n;i&&a.upload.addEventListener("progress",d=>{d.lengthComputable&&d.total>0&&i(Math.min(1,d.loaded/d.total));});let u=()=>{a.abort(),o(new Xe("Submit aborted."));};if(l){if(l.aborted){o(new Xe("Submit aborted."));return}l.addEventListener("abort",u,{once:true});}a.addEventListener("load",()=>{if(l&&l.removeEventListener("abort",u),a.status===403){o(new At);return}if(a.status===429){let d=Number(a.getResponseHeader("Retry-After"))||60;o(new Nt(d));return}if(a.status<200||a.status>=300){o(new A(gr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let d=JSON.parse(a.responseText);r(d);}catch{o(new A("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{l&&l.removeEventListener("abort",u),o(new Xe("Network error during submit."));}),a.send(t);})}};function pr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function fr(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 hr=2,br=1.5,vr=820,wr=12,He=8*1024*1024;async function Qe(e={}){Gt();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return Sr(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 A("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return Bt(e);if(t==="dom")return Dt(e);if(t==="custom")throw new A("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await Dt(e)}catch(n){if(Yt()){let r=await Bt(e);return r.warnings=Ve(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function _e(e,t=[]){Gt();let n=et();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:Ve(t)}}var It=Promise.resolve();function Dt(e){let t=It.then(()=>Ot(e),()=>Ot(e));return It=t.catch(()=>{}),t}async function Ot(e){let t=await kr(),n=e.target??document.documentElement,r=et(),o=Lr(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),l=window.scrollY+(a?.offsetTop??0),u=Tr(e,r.width,r.height),d=Mr(n);!e.provider&&xr()&&d.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 c=Rr(n);await jt(e.awaitAnimationsMs??Nr),await Ar();let f=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:l,scale:u,ignoreElements:g=>g instanceof HTMLElement&&(g.dataset.lumenCaptureIgnore==="true"||!!g.closest("[data-lumen-capture-ignore='true']")),onclone:(g,p)=>{Cr(p,c),yr(g);}}),v={blob:await qt(f,d),method:"web-dom",platform:"web",viewport:r,pixelRatio:u,warnings:Ve(d)};return v.warnings.length>0&&e.onWarning?.(v.warnings),v}var Kt=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function yr(e){for(let t of Array.from(e.querySelectorAll(Kt))){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 Er="[data-lumen-root], [data-lumen-capture-ignore='true']";function zt(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(Er))}function Rr(e){return zt(e).map(t=>{if(t.matches(Kt))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 Cr(e,t){let n=zt(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 xr(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function kr(){let{default:e}=await import('html2canvas-pro');return e}async function Bt(e){if(!Yt())throw new A("Browser screen capture is unavailable in this environment.","DISPLAY_MEDIA_UNAVAILABLE");let t=await navigator.mediaDevices.getDisplayMedia({video:true,audio:false});try{let n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await Ir(n);let r=document.createElement("canvas");r.width=n.videoWidth,r.height=n.videoHeight;let o=r.getContext("2d");if(!o)throw new A("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");o.drawImage(n,0,0,r.width,r.height);let a=et(),i=["Browser screen capture uses the window or tab selected by the user."],l={blob:await qt(r,i),method:"web-display-media",platform:"web",viewport:a,pixelRatio:a.width>0?r.width/a.width:void 0,warnings:Ve(i)};return e.onWarning?.(l.warnings),l}finally{for(let n of t.getTracks())n.stop();}}function Sr(e,t){let n=et(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:Ve(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function Mr(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 qt(e,t){let n=await Ht(e,"image/png",.92);if(n.size<=He)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>He&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(He/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 l=i.getContext("2d");if(!l)return n;l.drawImage(r,0,0,i.width,i.height),r=i;for(let u of [.86,.74,.62,.5])if(n=await Ht(r,"image/jpeg",u),n.size<=He)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>He&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function Ht(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new A("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function et(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function Lr(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function Tr(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??hr;Pr()&&(o=Math.min(o,br));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(wr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function Pr(){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<=vr}function Ar(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var Nr=400;async function jt(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 Yt(){return !!navigator.mediaDevices?.getDisplayMedia}async function Ir(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new A("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 A("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}function Gt(){if(typeof window>"u"||typeof document>"u")throw new A("Screenshot capture can only run in the browser.","INVALID_ENV")}function Ve(e){return Array.from(new Set(e.filter(Boolean)))}var Xt=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i;function mt(e){let t=e;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:Xt.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[\w.+-]+@[\w-]+\.[\w.-]+\b/g,"***@***"),t}function Jt(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])Xt.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 Zt(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return Jt(e)}}var _t=200,Vt=4096,Qt=[],Je=[],Ft=false,pt=null;function en(e={}){Ft||typeof window>"u"||(Ft=true,pt=e.ignoreUrlPrefix??null,Hr(),_r(),Vr());}function Dr(){return {consoleLog:Qt.slice(),networkLog:Je.slice()}}function Ze(e,t){e.push(t),e.length>_t&&e.splice(0,e.length-_t);}function Or(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?`
3
- ${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,Br));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>Vt?n.slice(0,Vt)+"\u2026[truncated]":n}function Br(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Hr(){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{Ze(Qt,{level:n,ts:Date.now(),message:mt(Or(o))});}catch{}r(...o);});}}function tn(e){return pt?e.startsWith(pt):false}function _r(){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(tn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return Ze(Je,{type:"fetch",method:o,url:ft(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw Ze(Je,{type:"fetch",method:o,url:ft(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Vr(){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&&!tn(o.url)){o.t=performance.now();let a=()=>{try{Ze(Je,{type:"xhr",method:o.method,url:ft(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 Fr(e){return e.length>512?e.slice(0,512)+"\u2026":e}function ft(e){return Fr(Jt(e))}function nn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:Ut(e),consoleLog:[],networkLog:[]};let t=Dr();return {url:Zt(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:Ut(e),device:Ur(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function Ur(){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?Zt(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 Ut(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var Wr="[data-lumen-root]",$r="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function Kr(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(gt(n))return true;return gt(e.target)}var Wt=["pointerdown","mousedown","touchstart","click"];function zr(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of Wt)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of Wt)e.removeEventListener(n,t);}}function gt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches($r)?true:!!e.closest(Wr):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?gt(e.host):false:false}var tt="lumen:shake",qr=8e3,jr=50,Yr=400,Gr='[data-lumen-root], [data-lumen-capture-ignore="true"]';function Xr(e={}){return async function(){if(typeof window>"u")throw new A("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=Zr(),n=e.send??Jr,r=e.timeoutMs??qr,o=e.captureSettleMs??jr,a=e.awaitAnimationsMs??Yr,i=oo(),l=eo(e.concealSelector===void 0?Gr:e.concealSelector);try{await to(o,a);let u=await new Promise((f,v)=>{let g=window.setTimeout(()=>{t.pending.delete(i),v(new A("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:p=>{window.clearTimeout(g),f(p);},reject:p=>{window.clearTimeout(g),v(p);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(g),v(new A("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(u.error||!u.dataUrl)throw new A(u.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let d=ao(u.dataUrl),c=e.platform??ro();return {blob:d,method:c==="android"?"android-native":"ios-native",platform:c,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:u.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{l();}}}function Jr(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new A("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function Zr(){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=Qr(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 Qr(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}function eo(e){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;}}async function to(e,t){await jt(t),await no(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function no(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function ro(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function oo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function ao(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new A("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 l=0;l<a.length;l++)i[l]=a.charCodeAt(l);return new Blob([i],{type:n})}var Fe="lumen:keyboardchange",ht="--lumen-keyboard-inset";function io(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(ht,`${t}px`),window.dispatchEvent(new Event(Fe));}function bt(){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(ht).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function rn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new A("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new A("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(g=>MediaRecorder.isTypeSupported(g))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,l=false,u=false,d,c,f=new Promise((g,p)=>{d=g,c=p;});f.catch(()=>{}),r.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&o.push(g.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let S of t.getTracks())S.stop();if(u)return;if(u=true,l){c(new A("Recording cancelled.","RECORDER_STOPPED"));return}let g=performance.now()-a,p=r.mimeType||n||"audio/webm",E=new Blob(o,{type:p});d({blob:E,durationMs:g,mimeType:p});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function v(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){l=true,v(),i!==null&&window.clearTimeout(i),i=null;for(let g of t.getTracks())g.stop();},stop(){return v(),f}}}async function on(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new A("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new A("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(p=>MediaRecorder.isTypeSupported(p))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,l=false,u=false,d,c,f=new Promise((p,E)=>{d=p,c=E;});f.catch(()=>{});function v(){i!==null&&(window.clearTimeout(i),i=null);for(let p of t.getTracks())p.stop();}r.addEventListener("dataavailable",p=>{p.data&&p.data.size>0&&o.push(p.data);}),r.addEventListener("stop",()=>{if(l)return;if(l=true,v(),u){c(new A("Recording cancelled.","RECORDER_STOPPED"));return}let p=r.mimeType||n||"video/webm";d({blob:new Blob(o,{type:p}),durationMs:performance.now()-a,mimeType:p});});function g(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(g,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",g),{stream:t,result:f,stop:g,cancel(){u=true,r.state!=="inactive"?r.stop():l||(l=true,v(),c(new A("Recording cancelled.","RECORDER_STOPPED")));}}}var vt=dn.createContext(null);function Ue(){let e=dn.useContext(vt);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var an=100;function sn(){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 We={open:false,inset:0};function mo(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:We}if(e.vvHeight==null||!e.coarse||!e.editable)return We;let n=e.vvBaseline-e.vvHeight;return n>an?{open:true,inset:Math.round(n)}:We}function $e(e,t){let[n,r]=dn.useState(We),o=dn.useRef(0),a=dn.useRef(t);return a.current=t,dn.useEffect(()=>{if(!e){r(We);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,l=()=>{let f=sn(),v=a.current,g=bt(),p=window.visualViewport??null;p&&v==null&&g==null&&!f&&(o.current=p.height),r(mo({editable:f,override:v,injected:g,vvBaseline:o.current,vvHeight:p?p.height:null,coarse:i}));},u=0,d=()=>{u||(u=window.requestAnimationFrame(()=>{u=0,l();}));},c=window.visualViewport;return c&&(o.current=c.height),d(),c?.addEventListener("resize",d),c?.addEventListener("scroll",d),document.addEventListener("focusin",d),document.addEventListener("focusout",d),window.addEventListener(Fe,d),()=>{u&&window.cancelAnimationFrame(u),c?.removeEventListener("resize",d),c?.removeEventListener("scroll",d),document.removeEventListener("focusin",d),document.removeEventListener("focusout",d),window.removeEventListener(Fe,d);}},[e]),n}var yt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function cn(e,t=1){return Math.max(0,Math.min(t,e))}var mn=dn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a},i){let l=dn.useRef(null),u=dn.useRef(null),d=dn.useRef(null),[c,f]=dn.useState(null),[v,g]=dn.useState([]),p=dn.useRef(null),E=dn.useRef(false),S=dn.useRef(0),C=dn.useRef(false),[x,R]=dn.useState([]),L=dn.useRef(0),N=dn.useRef([]),P=dn.useRef(null),K=dn.useCallback((h,w)=>{R(k=>k.map(M=>M.id===h?{...M,text:w}:M));},[]),I=dn.useCallback(h=>{R(k=>k.filter(M=>M.id!==h));let w=N.current.lastIndexOf("comment");w>=0&&N.current.splice(w,1);},[]);dn.useEffect(()=>{let h=P.current;if(h==null)return;P.current=null,d.current?.querySelector(`[data-bubble-id="${h}"] .lumen-bubble-text`)?.focus();},[x]),dn.useEffect(()=>{let h=false,w=null;return (async()=>{try{let k=await createImageBitmap(t);if(h){k.close?.();return}w=k,f(k);}catch{}})(),()=>{h=true,w?.close?.();}},[t]),dn.useEffect(()=>{if(!c)return;let h=l.current,w=u.current;if(!h||!w)return;h.width=c.width,h.height=c.height,w.width=c.width,w.height=c.height;let k=h.getContext("2d");k&&(k.imageSmoothingEnabled=false,k.drawImage(c,0,0));},[c]),dn.useEffect(()=>{let h=u.current;h&&nt(h,v,p.current);},[v]),dn.useImperativeHandle(i,()=>({hasAnnotations:()=>v.length>0||x.some(h=>h.text.trim().length>0),reset:()=>{g([]),R([]),N.current=[];},undo:()=>{(N.current.pop()??"anno")==="comment"?R(w=>w.length===0?w:w.slice(0,-1)):g(w=>w.length===0?w:w.slice(0,-1));},async flatten(){let h=p.current,w=h?[...v,h]:v,k=x.filter(_=>_.text.trim().length>0);if(w.length===0&&k.length===0||!c)return t;let M=document.createElement("canvas");M.width=c.width,M.height=c.height;let H=M.getContext("2d");if(!H)return t;H.imageSmoothingEnabled=false,H.drawImage(c,0,0);for(let _ of w)Et(H,_);let q=l.current?.clientWidth||c.width,X=c.width/Math.max(q,1);for(let _ of k)bo(H,_,c.width,c.height,X);return await new Promise(_=>{M.toBlob(ne=>{_(ne??t);},"image/jpeg",.85);})}}),[v,x,c,t]);function ee(h){let w=u.current;if(!w)return {x:0,y:0};let k=w.getBoundingClientRect(),M=w.width/Math.max(k.width,1),H=w.height/Math.max(k.height,1);return {x:(h.clientX-k.left)*M,y:(h.clientY-k.top)*H}}function V(){C.current||(C.current=true,requestAnimationFrame(()=>{C.current=false;let h=u.current;h&&nt(h,v,p.current);}));}function G(h){if(h.button!==void 0&&h.button!==0)return;if(n==="comment"){let k=u.current;if(!k)return;let M=k.getBoundingClientRect(),H=cn((h.clientX-M.left)/Math.max(M.width,1),.72),q=cn((h.clientY-M.top)/Math.max(M.height,1),.8),X=++L.current;R(_=>[..._,{id:X,x:H,y:q,text:"",color:r}]),N.current.push("comment"),P.current=X;return}try{h.currentTarget.setPointerCapture(h.pointerId);}catch{}E.current=true,a?.(true);let w=ee(h);n==="arrow"?p.current={kind:"arrow",from:w,to:w,color:r,width:o}:n==="rect"?p.current={kind:"rect",from:w,to:w,color:r,width:o}:p.current={kind:"freehand",points:[w],color:r,width:o},S.current=performance.now(),V();}function te(h){if(!E.current||!p.current)return;let w=ee(h),k=p.current;if(k.kind==="arrow"||k.kind==="rect")k.to=w;else {let M=k.points[k.points.length-1],H=M?(M.x-w.x)**2+(M.y-w.y)**2:1/0,q=performance.now(),X=q-S.current;(H>16||X>16)&&(k.points.push(w),S.current=q);}V();}function z(){if(!E.current)return;E.current=false,a?.(false);let h=p.current;if(p.current=null,!!h){if(h.kind==="arrow"||h.kind==="rect"){let w=h.to.x-h.from.x,k=h.to.y-h.from.y;if(w*w+k*k<16){let M=u.current;M&&nt(M,v,null);return}}else if(h.points.length<2){let w=u.current;w&&nt(w,v,null);return}g(w=>[...w,h].slice(-50)),N.current.push("anno");}}return jsxRuntime.jsxs("div",{ref:d,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:l}),jsxRuntime.jsx("canvas",{ref:u,className:"lumen-annotate-overlay",onPointerDown:G,onPointerMove:te,onPointerUp:z,onPointerCancel:z}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:x.map(h=>jsxRuntime.jsx(go,{comment:h,onChange:K,onRemove:I},h.id))})]})});function go({comment:e,onChange:t,onRemove:n}){let r=dn.useRef(null);return dn.useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxRuntime.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:[jsxRuntime.jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsxRuntime.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??"")}),jsxRuntime.jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function nt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)Et(r,o);n&&Et(r,n);}}function Et(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")ho(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 ho(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],l=(a.x+i.x)/2,u=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,l,u);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function bo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,l=14*o,u=10*o,d=12*o,c=l*1.35,f=u*1.7,v=t.x*n,g=t.y*r,p=Math.min(n*.6,n-v-8*o);e.save(),e.font=`500 ${l}px ${yt}`,e.textBaseline="top";let E=vo(e,a,p-i*2),S=E.reduce((P,K)=>Math.max(P,e.measureText(K).width),0),C=Math.min(p,Math.max(S,56*o)+i*2),x=i*2+f+E.length*c;wo(e,v,g,C,x,d),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let R=v+18*o,L=g+x;e.beginPath(),e.moveTo(R,L-o),e.lineTo(R+13*o,L-o),e.lineTo(R+4*o,L+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${u}px ${yt}`,e.fillText("COMMENT",v+i,g+i),e.fillStyle="#111318",e.font=`500 ${l}px ${yt}`;let N=g+i+f;for(let P of E)e.fillText(P,v+i,N),N+=c;e.restore();}function vo(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let l=a?`${a} ${i}`:i;a&&e.measureText(l).width>n?(o.push(a),a=i):a=l;}return a&&o.push(a),o.length?o:[t]}function wo(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let l=e;if(typeof l.roundRect=="function"){l.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 ze({children:e,...t}){return jsxRuntime.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 yo(e){return jsxRuntime.jsxs(ze,{...e,children:[jsxRuntime.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"}),jsxRuntime.jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function Eo(e){return jsxRuntime.jsxs(ze,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsxRuntime.jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Ro(e){return jsxRuntime.jsxs(ze,{...e,children:[jsxRuntime.jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsxRuntime.jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function fn(e){return jsxRuntime.jsxs(ze,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function gn(e){return jsxRuntime.jsxs(ze,{...e,children:[jsxRuntime.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var Rt={shot:yo,video:Eo,upload:Ro};function hn(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 Co(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 xo=4e3;async function Ct(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((u,d)=>{if(n.readyState>=2)return u();n.addEventListener("loadeddata",()=>u(),{once:true}),n.addEventListener("error",()=>d(new Error("video decode failed")),{once:true});}),await Co(n,Math.min(.1,(n.duration||0)/2));let i=await hn(n),l=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:l}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),xo);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function xt(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 hn(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 St=60,ko=25*1024*1024,bn=[{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)"}],vn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],wn=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],yn=[{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 Mt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:l,consumePendingVideo:u,canRecordScreen:d,consumeRecordStartError:c,isolateEvents:f,keyboardInset:v}=Ue(),[g,p]=dn.useState(1),[E,S]=dn.useState(null),[C,x]=dn.useState({kind:"idle"}),[R,L]=dn.useState(false),[N,P]=dn.useState(0),[K,I]=dn.useState(null),[ee,V]=dn.useState(false),[G,te]=dn.useState("arrow"),[z,h]=dn.useState(bn[0].value),[w,k]=dn.useState(vn[1].value),[M,H]=dn.useState(""),[q,X]=dn.useState("bug"),[_,ne]=dn.useState(r?.email??""),[F,Ee]=dn.useState(null),[J,Re]=dn.useState(null),[st,re]=dn.useState(0),[W,fe]=dn.useState(null),[Ae,oe]=dn.useState(null),[ce,de]=dn.useState(false),$=dn.useRef(null),Ce=dn.useRef(null),be=dn.useRef(null),xe=dn.useRef(null),ve=$e(t,v),me=dn.useRef(false),ke=dn.useRef(false);dn.useEffect(()=>{t||(ke.current=false);},[t]),dn.useEffect(()=>{if(!t)return;if(ke.current){me.current=false;return}ke.current=true,me.current=false,p(1),S(null),H(""),Re(null),re(0),fe(null),L(false),P(0),I(null),V(false),oe(null);let s=u();if(s)S("video"),fe({blob:s.blob,durationMs:s.durationMs}),s.blob.size>ko&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),s.poster?x({kind:"ready",capture:_e(s.poster,["Screen recording; preview is the first frame."])}):(x({kind:"capturing"}),(async()=>{let b=null;if(s.deriveBlobPoster)try{b=(await Ct(s.blob)).poster;}catch{b=null;}b=b??await kt(),!me.current&&x(b?{kind:"ready",capture:_e(b,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let b=c();b?(S("video"),oe(b),x({kind:"idle"})):a?(S("shot"),x({kind:"ready",capture:a})):o?.mode==="manual"?x({kind:"manual"}):o?.provider&&!i?(S("shot"),Ne(o.mode??"auto")):x({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{me.current=true;}},[t,o,a,i]),dn.useEffect(()=>{if(!t)return;xe.current=document.activeElement??null;let s=document.documentElement,b=s.style.overflow,B=s.style.paddingRight,j=window.innerWidth-s.clientWidth;s.style.overflow="hidden",j>0&&(s.style.paddingRight=`${j}px`);let Z=false,we=()=>{if(!Z){Z=true,s.style.overflow=b,s.style.paddingRight=B;try{xe.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",we),()=>{window.removeEventListener("pagehide",we),we();}},[t]),dn.useEffect(()=>{if(!t)return;function s(b){if(b.key==="Escape"){b.preventDefault(),n();return}if(b.key!=="Tab")return;let B=Ce.current;if(!B)return;let j=Oo(B);if(j.length===0)return;let Z=j[0],we=j[j.length-1],dt=document.activeElement;b.shiftKey&&(dt===Z||!B.contains(dt))?(b.preventDefault(),we.focus()):!b.shiftKey&&dt===we&&(b.preventDefault(),Z.focus());}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),dn.useEffect(()=>{if(!t||!f)return;let s=be.current;if(!s)return;let b=B=>{B.target===s&&B.stopPropagation();};return s.addEventListener("pointerdown",b),s.addEventListener("click",b),s.addEventListener("touchstart",b,{passive:true}),()=>{s.removeEventListener("pointerdown",b),s.removeEventListener("click",b),s.removeEventListener("touchstart",b);}},[t,f]),dn.useEffect(()=>{if(!t||!ve.open)return;let s=Ce.current,b=document.activeElement;if(s&&b&&s.contains(b))try{b.scrollIntoView({block:"center"});}catch{}},[t,ve.open,ve.inset]),dn.useEffect(()=>{if(!t||C.kind!=="manual")return;function s(b){let Z=Array.from(b.clipboardData?.items??[]).find(we=>we.type.startsWith("image/"))?.getAsFile();Z&&(b.preventDefault(),Oe(Z));}return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[t,C.kind]),dn.useEffect(()=>{if(!F)return;let s=Date.now(),b=window.setInterval(()=>{let B=Math.floor((Date.now()-s)/1e3);re(B),B>=St&&Be();},250);return ()=>window.clearInterval(b)},[F]);let ge=dn.useRef(null);if(ge.current=F,dn.useEffect(()=>{t||ge.current&&(ge.current.cancel(),ge.current=null,Ee(null),re(0));},[t]),dn.useEffect(()=>()=>{ge.current?.cancel();},[]),!t)return null;async function Ne(s){me.current=false,x({kind:"capturing"});try{let b=await Qe({...o,mode:s,target:o?.target??document.documentElement});return me.current?!1:(Ye(b),x({kind:"ready",capture:b}),!0)}catch(b){return me.current||x({kind:"manual",error:b instanceof Error?b.message:"Automatic screenshot capture was unavailable."}),false}}async function Se(s){S(s),oe(null),I(null),s!=="video"&&D(),s==="shot"?await Ne(o?.mode??"auto"):s==="video"?(fe(null),x({kind:"idle"})):x({kind:"manual"});}async function Oe(s){if(s.type.startsWith("image/")){D();let b=_e(s,["Manual image upload used."]);x({kind:"ready",capture:b});return}if(s.type.startsWith("video/")){x({kind:"capturing"});try{let{poster:b,durationMs:B}=await Ct(s),j=b??await kt();if(!j){x({kind:"manual",error:"Could not read that video."});return}let Z=_e(j,["Uploaded video; preview is the first frame."]);fe({blob:s,durationMs:B}),x({kind:"ready",capture:Z});}catch{x({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function Ye(s){s.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function Me(){try{let s=await rn(St);Ee(s);}catch(s){sonner.toast.error(s instanceof Error?s.message:"Microphone unavailable");}}async function Be(){if(F)try{let s=await F.stop();Re({blob:s.blob,durationMs:s.durationMs});}catch(s){sonner.toast.error(s instanceof Error?s.message:"Could not stop recording");}finally{Ee(null);}}function lt(){F?.cancel(),Ee(null),Re(null),re(0);}function ae(s){let b=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!F&&!J?jsxRuntime.jsxs("button",{type:"button",onClick:Me,className:s==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(gn,{}),"Record voice note"]}):null,F?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(Po,{stream:F.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[st,"s / ",St,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:Be,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:lt,className:"lumen-btn-ghost",children:"Cancel"})]}):null,J&&!F?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(No,{blob:J.blob,durationMs:J.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Re(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return s==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[b,!F&&!J?jsxRuntime.jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),b]})}async function T(){oe(null);try{await l();}catch(s){sonner.toast.error(s instanceof Error?s.message:"Screen capture unavailable");}}function D(){fe(null);}let U=C.kind==="ready";async function ut(){if(F&&await Be(),g===1){if(C.kind==="ready"){let s=await $.current?.flatten();I(s??C.capture.blob),V(s!=null&&s!==C.capture.blob);}p(2);}else g===2?p(3):await or();}function rr(){g>1&&p(s=>s-1);}async function or(){if(C.kind!=="ready")return;let s=M.trim(),{capture:b}=C;L(true),P(0);try{let B=K??b.blob,j=await e.submit({rawText:s.length>0?s:void 0,category:q,submitterEmail:_.trim()||void 0,screenshot:B,audio:J?.blob,audioDurationMs:J?.durationMs,video:W?.blob,videoDurationMs:W?.durationMs,context:nn(b)},{onUploadProgress:Z=>P(Math.min(.95,Z))});P(1),sonner.toast.success("Feedback sent \u2014 thank you."),j.id,n();}catch(B){sonner.toast.error(B instanceof Error?B.message:"Could not submit feedback"),L(false);}}function ar(s){s.target===s.currentTarget&&!R&&n();}let Ge=Math.round(N*100),ct=E==="video",ir=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,sr=E==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&ir,lr=g===1&&!U||R,ur=g<3?"Next":R?Ge<95?`Uploading ${Ge}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:be,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:ve.inset?{"--lumen-keyboard-inset":`${ve.inset}px`}:void 0,onMouseDown:ar,children:jsxRuntime.jsxs("div",{ref:Ce,className:"lumen-modal","data-lumen-drawing":ce?"true":void 0,children:[jsxRuntime.jsx(To,{onDismiss:n}),jsxRuntime.jsxs("header",{className:"lumen-modal-header",children:[jsxRuntime.jsxs("h2",{className:"lumen-modal-title",children:[jsxRuntime.jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsx(So,{step:g}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[g===1?jsxRuntime.jsx("div",{className:"lumen-pane",children:E===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:yn.map(s=>{let b=Rt[s.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(s.primary?" lumen-method-primary":""),onClick:()=>Se(s.value),disabled:C.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(b,{})}),s.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]})]},s.value)})}),jsxRuntime.jsx("p",{className:"lumen-status lumen-method-help",children:"Choose how to capture your feedback."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method-switch",role:"group","aria-label":"Switch capture method",children:yn.map(s=>{let b=Rt[s.value];return jsxRuntime.jsxs("button",{type:"button","aria-pressed":E===s.value,onClick:()=>Se(s.value),disabled:C.kind==="capturing",children:[jsxRuntime.jsx(b,{}),s.label]},s.value)})}),E==="video"&&C.kind==="idle"?jsxRuntime.jsx(Mo,{canRecord:d,onRecord:T,onUpload:()=>Se("upload"),error:Ae}):null,C.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,C.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:E==="upload"?"Choose an image or video to attach \u2014 or paste an image.":C.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:E==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:E==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:s=>{let b=s.currentTarget.files?.[0];b&&Oe(b),s.currentTarget.value="";}})]})]}):null,C.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[ct?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(rt,{label:"Arrow",active:G==="arrow",onClick:()=>te("arrow")}),jsxRuntime.jsx(rt,{label:"Box",active:G==="rect",onClick:()=>te("rect")}),jsxRuntime.jsx(rt,{label:"Draw",active:G==="freehand",onClick:()=>te("freehand")}),jsxRuntime.jsx(rt,{label:"Comment",active:G==="comment",onClick:()=>te("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:bn.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:s.value},"aria-label":s.label,"aria-pressed":z===s.value,onClick:()=>h(s.value)},s.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:vn.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":s.label,"aria-pressed":w===s.value,onClick:()=>k(s.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:s.dot,height:s.dot}})},s.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>$.current?.undo(),children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>$.current?.reset(),children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(mn,{ref:$,screenshot:C.capture.blob,tool:G,color:z,strokeWidth:w,onDrawingChange:de})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>E&&Se(E),children:ct?"\u21BB Re-record":"\u21BB Recapture"}),sr?jsxRuntime.jsxs("button",{type:"button",className:"lumen-btn-ghost lumen-exact-btn",onClick:()=>{Ne("true-screen");},title:"Capture the real screen pixels \u2014 your browser will ask which tab or window to share.",children:[jsxRuntime.jsx(fn,{})," Capture exact screen"]}):null,ct?W?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(W.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:C.capture.method==="web-display-media"?"Exact screen captured":`${En(E)} captured \xB7 switch method above anytime`})]}),ae("capture")]}):null]})}):null,g===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:M,onChange:s=>H(s.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),ae("describe"),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:wn.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":q===s.value,onClick:()=>X(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:_,onChange:s=>ne(s.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,g===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[En(E),ee?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>p(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:wn.find(s=>s.value===q)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>p(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[M.trim()?M.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>p(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[J?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(J.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>Re(null),children:"\xD7"})]}):null,W?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(W.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:D,children:"\xD7"})]}):null,_.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",_.trim()]}):null,!J&&!F?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{p(2),Me();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[R?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Ge,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${Ge}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:g===1?n:rr,className:"lumen-btn-ghost",disabled:R,children:g===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:ut,className:"lumen-btn-primary",disabled:lr,children:ur})]})]})]})})}function En(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function So({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsxRuntime.jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxRuntime.jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsxRuntime.jsx("span",{className:"lumen-step-num",children:n.n}),jsxRuntime.jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function Mo({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[r?jsxRuntime.jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsxRuntime.jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsxRuntime.jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxRuntime.jsxs("div",{className:"lumen-record-copy",children:[jsxRuntime.jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsxRuntime.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."})]})]}):jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[jsxRuntime.jsx("p",{className:"lumen-record-unavailable",children:Lo()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function Lo(){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 rt({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function To({onDismiss:e}){let t=dn.useRef(null),n=dn.useRef(0),r=dn.useRef(null);function o(l){l.currentTarget.setPointerCapture(l.pointerId),t.current=l.clientY,n.current=performance.now(),r.current=l.currentTarget.parentElement;}function a(l){if(t.current==null||!r.current)return;let u=Math.max(0,l.clientY-t.current);r.current.style.transform=`translateY(${u}px)`;}function i(l){if(t.current==null||!r.current)return;let u=Math.max(0,l.clientY-t.current),d=Math.max(1,performance.now()-n.current),c=u/d;r.current.style.transform="",r.current.style.transition="",t.current=null,(u>80||c>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function Po({stream:e}){let t=dn.useRef(null);return dn.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 l=window.AudioContext??window.webkitAudioContext;if(!l)return;let u=new l,d=u.createMediaStreamSource(e),c=u.createAnalyser();c.fftSize=1024,c.smoothingTimeConstant=.6,d.connect(c);let f=new Uint8Array(c.fftSize),v=18,g=3,p=3,E=Math.max(2,(o-g*(v-1))/v),S=Math.min(E/2,3),C=new Array(v).fill(0),x=0,R=false;function L(){if(R)return;c.getByteTimeDomainData(f);let N=Math.floor(f.length/v);i.clearRect(0,0,o,a),i.fillStyle=Io("--lumen-danger")||"rgb(239,68,68)";for(let P=0;P<v;P++){let K=0;for(let z=0;z<N;z++){let h=Math.abs((f[P*N+z]??128)-128);h>K&&(K=h);}let I=Math.min(1,K/128*1.8),ee=C[P]??0;C[P]=I>ee?I:ee+(I-ee)*.35;let V=Math.max(p,C[P]*a),G=P*(E+g),te=(a-V)/2;Ao(i,G,te,E,V,S),i.fill();}x=requestAnimationFrame(L);}return x=requestAnimationFrame(L),()=>{R=true,cancelAnimationFrame(x);try{d.disconnect();}catch{}u.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function Ao(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let l=e;if(typeof l.roundRect=="function"){l.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 No({blob:e,durationMs:t}){let[n,r]=dn.useState("");return dn.useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxRuntime.jsxs("div",{className:"lumen-audio-preview",children:[jsxRuntime.jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxRuntime.jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function Io(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var Do='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Oo(e){return Array.from(e.querySelectorAll(Do)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var ot=class extends dn__namespace.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t){if(typeof document<"u"){let n=document.documentElement;n.style.overflow="",n.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),sonner.toast.error("Feedback widget hit a snag and was reset. Please try again."),Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function Sn({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=dn.useState(false);if(dn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(Ho,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):reactDom.createPortal(jsxRuntime.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:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function Ho({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=dn.useState(0);dn.useEffect(()=>{let l=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));l();let u=window.setInterval(l,250);return ()=>window.clearInterval(u)},[e,t]);let i=l=>`${Math.floor(l/60)}:${String(l%60).padStart(2,"0")}`;return jsxRuntime.jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxRuntime.jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxRuntime.jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function Lt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function Mn(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function Ln(e){return e instanceof Error?e:new Error(String(e))}function Tn(e,t,n){let r=false,o=false,a=false,i=null;function l(){o||(o=true,n.onCancelled());}function u(c){o||(o=true,n.onResult(c));}function d(c){o||(o=true,n.onError(c));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(c=>{if(i=c,r){try{c.cancel();}catch{}l();return}if(n.onActive(c),a){n.onProcessing();try{c.stop();}catch{}}Promise.resolve(c.result).then(f=>{r?l():u(f);}).catch(f=>{r||Mn(f)?l():d(Ln(f));});}).catch(c=>{r||Mn(c)?l():d(Ln(c));}),{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{}l();}}}}function Pn(){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 l=document.elementsFromPoint(i,n);for(let u of l){if(o.has(u))continue;o.add(u);let d=window.getComputedStyle(u);if(d.position!=="fixed"&&d.position!=="sticky")continue;let c=u.getBoundingClientRect();c.bottom<t-8||c.bottom>t+8||c.width<e*.6||c.height>a&&(a=c.height);}}return a}function Tt(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 l of Array.from(i)){let u=l.getBoundingClientRect();if(u.height===0||u.width===0)continue;let d=0;switch(t){case "bottom":if(u.bottom<r-8)break;d=Math.max(0,r-u.top);break;case "top":if(u.top>8)break;d=Math.max(0,u.bottom);break;case "left":if(u.left>8)break;d=Math.max(0,u.right);break;case "right":if(u.right<n-8)break;d=Math.max(0,n-u.left);break}d>o&&(o=d);}}return o}function An(e){let[t,n]=dn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=dn.useRef(t),o=Uo(e.avoid),a=e.placement,i=e.offset.x,l=e.offset.y;return dn.useEffect(()=>{if(typeof window>"u")return;let u=0,d=false,c=()=>{if(u=0,d)return;let E=a[0]==="b"?"bottom":"top",S=a[1]==="r"?"right":"left",C=0,x=0;e.avoid==="auto"&&E==="bottom"?C=Pn():Array.isArray(e.avoid)&&(C=Tt(e.avoid,E),x=Tt(e.avoid,S));let R={bottom:E==="bottom"?l+C:0,top:E==="top"?l+C:0,right:S==="right"?i+x:0,left:S==="left"?i+x:0},L=r.current;(R.bottom!==L.bottom||R.top!==L.top||R.right!==L.right||R.left!==L.left)&&(r.current=R,n(R));},f=()=>{u||(u=window.requestAnimationFrame(c));};f();let v=typeof ResizeObserver<"u"?new ResizeObserver(f):null;v?.observe(document.documentElement);let g=typeof MutationObserver<"u"?new MutationObserver(f):null;g?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",f);let p=window.visualViewport;return p?.addEventListener("resize",f),p?.addEventListener("scroll",f),()=>{d=true,u&&window.cancelAnimationFrame(u),v?.disconnect(),g?.disconnect(),window.removeEventListener("resize",f),p?.removeEventListener("resize",f),p?.removeEventListener("scroll",f);}},[a,i,l,o]),t}function Uo(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var Nn=["mousedown","touchstart"];function Ie(e){let t=dn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=dn.useRef(e.onClick);n.current=e.onClick;let r=dn.useRef(e.isolate??true);r.current=e.isolate??true;let o=dn.useRef(null);return dn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=d=>{r.current&&d.stopPropagation(),t.current?.(d);},l=d=>{r.current&&d.stopPropagation(),n.current(d);},u=d=>{r.current&&d.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",l);for(let d of Nn)a.addEventListener(d,u,d==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",l);for(let d of Nn)a.removeEventListener(d,u);};},[])}function Bn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[l,u]=dn.useState(null),d=dn.useRef(null),c=An(e),f=$e(e.keyboard!=="off",i),v=Ie({onPointerDown:r,onClick:o,isolate:a}),g=dn.useCallback(I=>{d.current=I,v(I);},[v]);dn.useEffect(()=>{typeof document>"u"||u(t??document.body);},[t]);let p=e.placement,E=p[0]==="b"?"bottom":"top",S=p[1]==="r"?"right":"left",C=E==="bottom",x=f.open&&C&&(e.keyboard==="lift"||e.keyboard==="auto"&&f.inset>0)?f.inset:0,R=f.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&C&&f.inset<=0);if(qo(d,!n&&!R),!l)return null;let L=E==="bottom"?c.bottom:c.top,N=S==="right"?c.right:c.left,P=n||R,K={position:"fixed",[E]:e.safeArea?`calc(${L}px + env(safe-area-inset-${E}, 0px))`:`${L}px`,[S]:e.safeArea?`calc(${N}px + env(safe-area-inset-${S}, 0px))`:`${N}px`,zIndex:e.zIndex,transform:x?`translateY(-${x}px)`:void 0,opacity:P?0:1,pointerEvents:P?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:g,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:K,"aria-label":e.label,"aria-hidden":P?true:void 0,tabIndex:P?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),l)}function qo(e,t){let n=dn.useRef(false);dn.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,l=a.top+a.height/2,u=document.elementsFromPoint(i,l),d=In(window.getComputedStyle(o).zIndex);for(let c of u){if(c===o||o.contains(c))continue;if(In(window.getComputedStyle(c).zIndex)>d){n.current=true,console.warn("[lumen] trigger is occluded by",c);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function In(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function Hn({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,l]=dn.useState(null),u=Ie({onPointerDown:r,onClick:o,isolate:a});return dn.useEffect(()=>{if(typeof document>"u")return;let d=e instanceof HTMLElement?e:e.current??null;l(d);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:u,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),i):null}function Fn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,l]=dn.useState(null),[u,d]=dn.useState(false),c=dn.useRef(null),f=Ie({onPointerDown:S=>{r?.(S),c.current={x:S.clientX,y:S.clientY},d(true);let C=S.currentTarget;try{C?.setPointerCapture?.(S.pointerId);}catch{}},onClick:o,isolate:a});if(dn.useEffect(()=>{typeof document>"u"||l(t??document.body);},[t]),!i)return null;let v=`lumen-notch lumen-notch-${e.edge}${u?" lumen-notch-expanded":""}`;function g(S){let C=c.current;if(!C)return;let x=S.clientX-C.x,R=S.clientY-C.y;(e.edge==="top"&&R>16||e.edge==="bottom"&&R<-16||e.edge==="right"&&x<-16||e.edge==="left"&&x>16)&&(c.current=null,o(S.nativeEvent));}function p(){c.current=null,d(false);}function E(){c.current=null,d(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:f,type:"button",className:v,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:g,onPointerUp:p,onPointerCancel:E,onMouseEnter:()=>d(true),onMouseLeave:()=>d(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function Un(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function oa(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function Wn(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:oa(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var sa={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function $n(e){let t=dn.useId();dn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${la(t)}`,o={},a=(i,l)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,l);};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,l]of Object.entries(sa)){let u=e[l];typeof u=="string"&&u.length>0&&a(i,u);}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,l]of Object.entries(o))i.startsWith("--")?l?n.style.setProperty(i,l):n.style.removeProperty(i):l==null?n.removeAttribute(i):n.setAttribute(i,l);}},[e,t]);}function la(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Kn=Symbol.for("lumen.history.patched"),Pt="lumen:locationchange";function da(){if(typeof window>"u")return;let e=window;if(e[Kn])return;e[Kn]=true;let t=()=>window.dispatchEvent(new Event(Pt)),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 zn(e){let[t,n]=dn.useState(false);return dn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;da();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Pt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Pt,r),window.removeEventListener("popstate",r);}},[e]),t}var fa=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function qn(){let[e,t]=dn.useState(false);return dn.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||"";fa.some(a=>o.includes(a))&&t(true);},[]),e}var Yn="lumen.config.v1.",ba=3600*1e3;function Gn(e,t){let[n,r]=dn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return dn.useEffect(()=>{if(typeof window>"u")return;let o=Ca(e);o&&r({trigger:o.trigger,enabled:jn(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),l=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(l,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);let d=await u.json(),c=Xn(d.trigger);if(!c)throw new Error("Malformed config response");let f=ya(d.trigger),v=Jn(d.brand);xa(e,c,f,v),r({trigger:c,enabled:jn(c),shakeToOpen:f,brand:v,loading:false});}).catch(()=>{r(u=>u.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:u);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function jn(e){return e.kind!=="headless"}var va=["br","bl","tr","tl"],wa=["top","right","bottom","left"];function Xn(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:va.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:wa.find(o=>o===t.edge)??"top",label:n}:null}function ya(e){return !e||typeof e!="object"?false:e.shake===true}var Ea=/^#[0-9a-fA-F]{6}$/,Ra=["auto","light","dark"];function Jn(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&Ea.test(t.accent)?t.accent:null;if(!n)return null;let r=Ra.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 Ca(e){try{let t=window.localStorage.getItem(Yn+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>ba)return null;let r=Xn(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:Jn(n.brand)}:null}catch{return null}}function xa(e,t,n,r){try{window.localStorage.setItem(Yn+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function Sa(e){if(e&&typeof e=="object")return e.type===tt;if(typeof e=="string")try{return JSON.parse(e).type===tt}catch{return false}return false}function Ma(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(l,u,d,c){if(!a)return a={x:l,y:u,z:d,t:c},false;if(c-a.t<o)return false;let f=Math.abs(l-a.x)+Math.abs(u-a.y)+Math.abs(d-a.z);return a={x:l,y:u,z:d,t:c},f<t?false:(i=i.filter(v=>c-v<r),i.push(c),i.length>=n?(i=[],true):false)}}}function Zn(e,t,n){dn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let c=Date.now();n||c-r<o||(r=c,t());}let i=c=>{Sa(c.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let l=Ma(),u=c=>{let f=c.accelerationIncludingGravity??c.acceleration;!f||f.x==null||f.y==null||f.z==null||l.push(f.x,f.y,f.z,Date.now())&&a();},d=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return d&&window.addEventListener("devicemotion",u),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),d&&window.removeEventListener("devicemotion",u);}},[e,t,n]);}var er="https://shakebugs.vercel.app",it=60;function tr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function Ta({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:l,portalTarget:u,capture:d,record:c,shakeToOpen:f,onOpenChange:v,beforeOpen:g,onTriggerActivate:p,isolateEvents:E=true,keyboardInset:S,suppressTrigger:C=false,children:x}){let[R,L]=dn.useState(false),[N,P]=dn.useState(false),[K,I]=dn.useState(null),[ee,V]=dn.useState(null),[G]=dn.useState(false),[te]=dn.useState(null),z=dn.useRef(false),h=dn.useRef(false),w=dn.useRef(null),k=dn.useMemo(()=>new $t({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);dn.useEffect(()=>{en({ignoreUrlPrefix:(t??er).replace(/\/$/,"")});},[t]);let M=dn.useRef(v);M.current=v,dn.useEffect(()=>{if(!(typeof document>"u"))return R?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[R]);let H=dn.useRef(null);dn.useEffect(()=>{if(H.current===R)return;let T=H.current;H.current=R,T!==null&&M.current?.(R);},[R]);let q=dn.useRef(g);q.current=g;let X=dn.useRef(p);X.current=p;let _=dn.useCallback(T=>{h.current=true,w.current=Promise.resolve().then(()=>q.current?.(T)).then(()=>X.current?.(T)).then(()=>{});},[]),ne=dn.useCallback(T=>{z.current||R||de.current||(z.current=true,P(true),I(null),V(null),(async()=>{try{if(h.current?await w.current:(await q.current?.(T),await X.current?.(T)),d?.mode==="manual")I(null),V(null);else if(d?.provider)I(null),V(null);else {let D=await Qe({...d,mode:d?.mode??"auto",target:d?.target??document.documentElement});I(D);}}catch(D){V(D instanceof Error?D:new Error(String(D)));}finally{h.current=false,w.current=null,z.current=false,P(false),L(true);}})());},[d,R]),F=dn.useCallback(()=>{L(false),I(null),V(null);},[]),Ee=dn.useCallback(k.submit.bind(k),[k]),[J,Re]=dn.useState(0),st=dn.useCallback(()=>{z.current=false,P(false),L(false),I(null),V(null),Re(T=>T+1);},[]),[re,W]=dn.useState(null),[fe,Ae]=dn.useState(null),oe=dn.useRef(null),ce=dn.useRef(null),de=dn.useRef(false),$=dn.useRef(null),Ce=dn.useRef(null),be=dn.useRef(null),xe=dn.useCallback((T,D=false)=>{if(oe.current=null,ce.current=null,de.current=false,W(null),!T){$.current=null;return}Ce.current={blob:T.blob,durationMs:T.durationMs,poster:$.current,deriveBlobPoster:D},$.current=null,L(true);},[]);dn.useEffect(()=>{if(!R)return;if(!c?.provider){Ae(null);return}let T=c.isAvailable;if(!T){Ae(true);return}let D=false;return Promise.resolve().then(()=>T()).then(U=>{D||Ae(U);}).catch(()=>{D||Ae(false);}),()=>{D=true;}},[R,c?.provider,c?.isAvailable]);let ve=Lt({hasProvider:!!c?.provider,providerAvailable:fe,hasGetDisplayMedia:tr()}).canRecord,me=dn.useCallback(async()=>{if(de.current)return;if(be.current=null,Lt({hasProvider:!!c?.provider,providerAvailable:fe,hasGetDisplayMedia:tr()}).usingProvider&&c?.provider){de.current=true,$.current=null,L(false),ce.current=Tn(c.provider,{maxDurationSeconds:it},{onStarting:()=>W({phase:"starting"}),onActive:U=>{W({phase:"recording",stream:U.stream??null,startedAt:Date.now(),maxSeconds:it}),U.stream&&xt(U.stream).then(ut=>{$.current=ut;}).catch(()=>{});},onProcessing:()=>W({phase:"processing"}),onResult:U=>xe({blob:U.blob,durationMs:U.durationMs},true),onCancelled:()=>{ce.current=null,de.current=false,$.current=null,W(null),I(null),V(null),L(true);},onError:U=>{ce.current=null,de.current=false,$.current=null,W(null),be.current=U.message||"Screen recording could not start.",L(true);}});return}if(oe.current)return;let D=await on(it);oe.current=D,de.current=true,$.current=null,W({phase:"recording",stream:D.stream,startedAt:Date.now(),maxSeconds:it}),L(false),xt(D.stream).then(U=>{$.current=U;}).catch(()=>{}),D.result.then(U=>xe(U)).catch(()=>xe(null));},[xe,c?.provider,fe]),ke=dn.useCallback(()=>{ce.current?ce.current.stop():oe.current?.stop();},[]),ge=dn.useCallback(()=>{if(ce.current){ce.current.cancel();return}let T=oe.current;oe.current=null,de.current=false,$.current=null,W(null),T?.cancel(),I(null),V(null),L(true);},[]),Ne=dn.useCallback(()=>{let T=Ce.current;return Ce.current=null,T},[]),Se=dn.useCallback(()=>{let T=be.current;return be.current=null,T},[]);dn.useEffect(()=>{R||(be.current=null);},[R]);let Oe=qn(),Ye=zn(i),Me=Gn(a?"":e,t??er);$n(l??Na(Me.brand));let Be=f??Me.shakeToOpen;Zn(Be,ne,R);let lt=dn.useMemo(()=>({client:k,user:n,isOpen:R,isSubmitting:G,error:te,open:ne,close:F,openCapture:ne,closeCapture:F,submit:Ee,isNativeShell:Oe,capture:d,initialCapture:K,initialCaptureError:ee,isOpening:N,startVideoSession:me,stopVideoSession:ke,cancelVideoSession:ge,recording:re,consumePendingVideo:Ne,canRecordScreen:ve,consumeRecordStartError:Se,isolateEvents:E,keyboardInset:S}),[k,n,R,G,te,ne,F,Ee,Oe,d,K,ee,me,ke,ge,re,Ne,ve,Se,N,E,S]),ae=Aa({explicit:a,remote:Me.trigger,remoteLoading:Me.loading,floatingButton:o});return jsxRuntime.jsxs(vt.Provider,{value:lt,children:[x,jsxRuntime.jsxs(ot,{onReset:st,children:[ae?.kind==="floating"?jsxRuntime.jsx(Bn,{config:Wn(ae),portalTarget:u,hidden:Ye||C||N||re!=null,onPointerDown:_,onClick:T=>ne(T),isolateEvents:E,keyboardInset:S}):null,ae?.kind==="notch"?jsxRuntime.jsx(Fn,{config:Un(ae),portalTarget:u,hidden:Ye||C||N||re!=null,onPointerDown:_,onClick:T=>ne(T),isolateEvents:E}):null,ae?.kind==="inline"?jsxRuntime.jsx(Hn,{mount:ae.mount,label:ae.label??"Feedback",icon:ae.icon,onPointerDown:_,onClick:T=>ne(T),isolateEvents:E}):null,re?jsxRuntime.jsx(Sn,{state:re,portalTarget:u,onStop:ke,onCancel:ge}):null,jsxRuntime.jsx(Mt,{})]},J),jsxRuntime.jsx(Pa,{})]})}function Pa(){let[e,t]=dn.useState(false);return dn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Aa(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Na(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Ia({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=Ue(),l=["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 jsxRuntime.jsx("button",{type:"button",className:l,"data-lumen-trigger":"",onClick:u=>{o?.(u),u.defaultPrevented||i(u.nativeEvent);},...a,children:r})}
4
- exports.CaptureModal=Mt;exports.FeedbackButton=Ia;exports.LUMEN_KEYBOARD_CSS_VAR=ht;exports.LUMEN_KEYBOARD_EVENT=Fe;exports.LUMEN_SHAKE_MESSAGE=tt;exports.LumenProvider=Ta;exports.createNativeCaptureProvider=Xr;exports.isLumenEventTarget=Kr;exports.isolateLumenEvents=zr;exports.readLumenKeyboardInset=bt;exports.setLumenKeyboardInset=io;exports.useKeyboardInset=$e;exports.useLumen=Ue;//# sourceMappingURL=index.cjs.map
2
+ 'use strict';var Rn=require('react'),sonner=require('sonner'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Rn__namespace=/*#__PURE__*/_interopNamespace(Rn);var N=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},zt=class extends N{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},Kt=class extends N{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},at=class extends N{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},br="https://shakebugs.vercel.app",vr="/api/v1/sdk/submit",wr=new Set([502,503,504]),en=class{apiKey;apiUrl;user;amplitude;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new N("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??br).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${vr}`,r=this.#e(e),o=null;for(let a=0;a<3;a++){a>0&&await Er(2**a*250);try{return await this.#t(n,r,t)}catch(i){if(o=i,i instanceof zt||i instanceof Kt||i instanceof N&&typeof i.status=="number"&&!wr.has(i.status))throw i}}throw o instanceof Error?o:new at("Submit failed after 3 attempts.")}#e(e){let t=new FormData;e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),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,yr(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}#t(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:s}=n;i&&a.upload.addEventListener("progress",u=>{u.lengthComputable&&u.total>0&&i(Math.min(1,u.loaded/u.total));});let l=()=>{a.abort(),o(new at("Submit aborted."));};if(s){if(s.aborted){o(new at("Submit aborted."));return}s.addEventListener("abort",l,{once:true});}a.addEventListener("load",()=>{if(s&&s.removeEventListener("abort",l),a.status===403){o(new zt);return}if(a.status===429){let u=Number(a.getResponseHeader("Retry-After"))||60;o(new Kt(u));return}if(a.status<200||a.status>=300){o(new N(Cr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let u=JSON.parse(a.responseText);r(u);}catch{o(new N("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{s&&s.removeEventListener("abort",l),o(new at("Network error during submit."));}),a.send(t);})}};function yr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Er(e){return new Promise(t=>setTimeout(t,e))}function Cr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var tn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function nn(e=tn){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 Rr=2,Sr=1.5,xr=820,kr=12,$e=8*1024*1024;async function lt(e={}){kt();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return Ir(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 N("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return jt(e);if(t==="dom")return $t(e);if(t==="custom")throw new N("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await $t(e)}catch(n){if(ln()){let r=await jt(e);return r.warnings=je(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function qe(e,t=[]){kt();let n=ut();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:je(t)}}var Wt=Promise.resolve();function $t(e){let t=Wt.then(()=>qt(e),()=>qt(e));return Wt=t.catch(()=>{}),t}async function qt(e){let t=await Nr(),n=e.target??document.documentElement,r=ut(),o=Or(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),s=window.scrollY+(a?.offsetTop??0),l=Br(e,r.width,r.height),u=Dr(n);!e.provider&&Ar()&&u.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 d=Tr(n);await sn(e.awaitAnimationsMs??Vr),await Hr();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:s,scale:l,ignoreElements:w=>w instanceof HTMLElement&&(w.dataset.lumenCaptureIgnore==="true"||!!w.closest("[data-lumen-capture-ignore='true']")),onclone:(w,g)=>{Pr(g,d),Mr(w);}}),h={blob:await an(p,u),method:"web-dom",platform:"web",viewport:r,pixelRatio:l,warnings:je(u)};return h.warnings.length>0&&e.onWarning?.(h.warnings),h}var rn=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function Mr(e){for(let t of Array.from(e.querySelectorAll(rn))){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 Lr="[data-lumen-root], [data-lumen-capture-ignore='true']";function on(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(Lr))}function Tr(e){return on(e).map(t=>{if(t.matches(rn))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 Pr(e,t){let n=on(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 Ar(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function Nr(){let{default:e}=await import('html2canvas-pro');return e}async function xt(e={}){if(kt(),!ln())throw new N("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 Fr(n);}catch(i){for(let s of t.getTracks())s.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(s=>s());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let s=i?.conceal??true,l=s?nn():()=>{};try{s&&await Ur(r,3,400);let u=document.createElement("canvas");u.width=r.videoWidth,u.height=r.videoHeight;let d=u.getContext("2d");if(!d)throw new N("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");d.drawImage(r,0,0,u.width,u.height);let p=ut(),h=["Browser screen capture uses the window or tab selected by the user."],w={blob:await an(u,h),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?u.width/p.width:void 0,warnings:je(h)};return e.onWarning?.(w.warnings),w}finally{l();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function jt(e){let t=await xt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function Ir(e,t){let n=ut(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:je(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function Dr(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 an(e,t){let n=await Yt(e,"image/png",.92);if(n.size<=$e)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>$e&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt($e/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 s=i.getContext("2d");if(!s)return n;s.drawImage(r,0,0,i.width,i.height),r=i;for(let l of [.86,.74,.62,.5])if(n=await Yt(r,"image/jpeg",l),n.size<=$e)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>$e&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function Yt(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new N("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function ut(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function Or(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function Br(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??Rr;_r()&&(o=Math.min(o,Sr));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(kr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function _r(){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<=xr}function Hr(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var Vr=400;async function sn(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 ln(){return !!navigator.mediaDevices?.getDisplayMedia}async function Fr(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new N("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 N("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function Ur(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 s=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(s);};r(s),setTimeout(i,n);});}function kt(){if(typeof window>"u"||typeof document>"u")throw new N("Screenshot capture can only run in the browser.","INVALID_ENV")}function je(e){return Array.from(new Set(e.filter(Boolean)))}var un=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,zr=[/-----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 Kr(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 Et(e){let t=e;for(let n of zr)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:un.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=>Kr(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 cn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])un.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Et(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Et(e)}}function dn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return cn(e)}}var Gt=200,Zt=4096,mn=[],it=[],Xt=false,Ct=null;function pn(e={}){Xt||typeof window>"u"||(Xt=true,Ct=e.ignoreUrlPrefix??null,jr(),Yr(),Gr());}function Wr(){return {consoleLog:mn.slice(),networkLog:it.slice()}}function st(e,t){e.push(t),e.length>Gt&&e.splice(0,e.length-Gt);}function $r(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?`
3
+ ${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,qr));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>Zt?n.slice(0,Zt)+"\u2026[truncated]":n}function qr(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function jr(){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{st(mn,{level:n,ts:Date.now(),message:Et($r(o))});}catch{}r(...o);});}}function fn(e){return Ct?e.startsWith(Ct):false}function Yr(){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(fn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return st(it,{type:"fetch",method:o,url:Rt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw st(it,{type:"fetch",method:o,url:Rt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Gr(){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&&!fn(o.url)){o.t=performance.now();let a=()=>{try{st(it,{type:"xhr",method:o.method,url:Rt(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 Zr(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Rt(e){return Zr(cn(e))}function gn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:Jt(e),consoleLog:[],networkLog:[]};let t=Wr();return {url:dn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:Jt(e),device:Xr(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function Xr(){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?dn(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 Jt(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var Jr="[data-lumen-root]",Qr="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function eo(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(St(n))return true;return St(e.target)}var Qt=["pointerdown","mousedown","touchstart","click"];function to(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of Qt)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of Qt)e.removeEventListener(n,t);}}function St(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(Qr)?true:!!e.closest(Jr):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?St(e.host):false:false}var ct="lumen:shake",no=8e3,ro=50,oo=400;function ao(e={}){return async function(){if(typeof window>"u")throw new N("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=so(),n=e.send??io,r=e.timeoutMs??no,o=e.captureSettleMs??ro,a=e.awaitAnimationsMs??oo,i=po(),s=nn(e.concealSelector===void 0?tn:e.concealSelector);try{await uo(o,a);let l=await new Promise((p,h)=>{let w=window.setTimeout(()=>{t.pending.delete(i),h(new N("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:g=>{window.clearTimeout(w),p(g);},reject:g=>{window.clearTimeout(w),h(g);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(w),h(new N("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(l.error||!l.dataUrl)throw new N(l.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let u=fo(l.dataUrl),d=e.platform??mo();return {blob:u,method:d==="android"?"android-native":"ios-native",platform:d,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:l.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{s();}}}function io(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new N("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function so(){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=lo(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 lo(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 uo(e,t){await sn(t),await co(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function co(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function mo(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function po(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function fo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new N("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 s=0;s<a.length;s++)i[s]=a.charCodeAt(s);return new Blob([i],{type:n})}var Ye="lumen:keyboardchange",Mt="--lumen-keyboard-inset";function go(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(Mt,`${t}px`),window.dispatchEvent(new Event(Ye));}function Lt(){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(Mt).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function hn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new N("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new N("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(w=>MediaRecorder.isTypeSupported(w))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((w,g)=>{u=w,d=g;});p.catch(()=>{}),r.addEventListener("dataavailable",w=>{w.data&&w.data.size>0&&o.push(w.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let x of t.getTracks())x.stop();if(l)return;if(l=true,s){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let w=performance.now()-a,g=r.mimeType||n||"audio/webm",S=new Blob(o,{type:g});u({blob:S,durationMs:w,mimeType:g});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function h(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){s=true,h(),i!==null&&window.clearTimeout(i),i=null;for(let w of t.getTracks())w.stop();},stop(){return h(),p}}}async function bn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new N("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new N("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(g=>MediaRecorder.isTypeSupported(g))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((g,S)=>{u=g,d=S;});p.catch(()=>{});function h(){i!==null&&(window.clearTimeout(i),i=null);for(let g of t.getTracks())g.stop();}r.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&o.push(g.data);}),r.addEventListener("stop",()=>{if(s)return;if(s=true,h(),l){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let g=r.mimeType||n||"video/webm";u({blob:new Blob(o,{type:g}),durationMs:performance.now()-a,mimeType:g});});function w(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(w,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",w),{stream:t,result:p,stop:w,cancel(){l=true,r.state!=="inactive"?r.stop():s||(s=true,h(),d(new N("Recording cancelled.","RECORDER_STOPPED")));}}}var Tt=Rn.createContext(null);function Ge(){let e=Rn.useContext(Tt);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var vn=100;function wn(){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 Ze={open:false,inset:0};function yo(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:Ze}if(e.vvHeight==null||!e.coarse||!e.editable)return Ze;let n=e.vvBaseline-e.vvHeight;return n>vn?{open:true,inset:Math.round(n)}:Ze}function Xe(e,t){let[n,r]=Rn.useState(Ze),o=Rn.useRef(0),a=Rn.useRef(t);return a.current=t,Rn.useEffect(()=>{if(!e){r(Ze);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,s=()=>{let p=wn(),h=a.current,w=Lt(),g=window.visualViewport??null;g&&h==null&&w==null&&!p&&(o.current=g.height),r(yo({editable:p,override:h,injected:w,vvBaseline:o.current,vvHeight:g?g.height:null,coarse:i}));},l=0,u=()=>{l||(l=window.requestAnimationFrame(()=>{l=0,s();}));},d=window.visualViewport;return d&&(o.current=d.height),u(),d?.addEventListener("resize",u),d?.addEventListener("scroll",u),document.addEventListener("focusin",u),document.addEventListener("focusout",u),window.addEventListener(Ye,u),()=>{l&&window.cancelAnimationFrame(l),d?.removeEventListener("resize",u),d?.removeEventListener("scroll",u),document.removeEventListener("focusin",u),document.removeEventListener("focusout",u),window.removeEventListener(Ye,u);}},[e]),n}var At='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Cn(e,t=1){return Math.max(0,Math.min(t,e))}var Sn=Rn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a},i){let s=Rn.useRef(null),l=Rn.useRef(null),u=Rn.useRef(null),[d,p]=Rn.useState(null),[h,w]=Rn.useState([]),g=Rn.useRef(null),S=Rn.useRef(false),x=Rn.useRef(0),M=Rn.useRef(false),[L,b]=Rn.useState([]),C=Rn.useRef(0),I=Rn.useRef([]),A=Rn.useRef(null),q=Rn.useCallback((f,y)=>{b(k=>k.map(T=>T.id===f?{...T,text:y}:T));},[]),D=Rn.useCallback(f=>{b(k=>k.filter(T=>T.id!==f));let y=I.current.lastIndexOf("comment");y>=0&&I.current.splice(y,1);},[]);Rn.useEffect(()=>{let f=A.current;if(f==null)return;A.current=null,u.current?.querySelector(`[data-bubble-id="${f}"] .lumen-bubble-text`)?.focus();},[L]),Rn.useEffect(()=>{let f=false,y=null;return (async()=>{try{let k=await createImageBitmap(t);if(f){k.close?.();return}y=k,p(k);}catch{}})(),()=>{f=true,y?.close?.();}},[t]),Rn.useEffect(()=>{if(!d)return;let f=s.current,y=l.current;if(!f||!y)return;f.width=d.width,f.height=d.height,y.width=d.width,y.height=d.height;let k=f.getContext("2d");k&&(k.imageSmoothingEnabled=false,k.drawImage(d,0,0));},[d]),Rn.useEffect(()=>{let f=l.current;f&&dt(f,h,g.current);},[h]),Rn.useImperativeHandle(i,()=>({hasAnnotations:()=>h.length>0||L.some(f=>f.text.trim().length>0),reset:()=>{w([]),b([]),I.current=[];},undo:()=>{(I.current.pop()??"anno")==="comment"?b(y=>y.length===0?y:y.slice(0,-1)):w(y=>y.length===0?y:y.slice(0,-1));},async flatten(){let f=g.current,y=f?[...h,f]:h,k=L.filter(F=>F.text.trim().length>0);if(y.length===0&&k.length===0||!d)return t;let T=document.createElement("canvas");T.width=d.width,T.height=d.height;let V=T.getContext("2d");if(!V)return t;V.imageSmoothingEnabled=false,V.drawImage(d,0,0);for(let F of y)Nt(V,F);let K=s.current?.clientWidth||d.width,j=d.width/Math.max(K,1);for(let F of k)xo(V,F,d.width,d.height,j);return await new Promise(F=>{T.toBlob(oe=>{F(oe??t);},"image/jpeg",.85);})}}),[h,L,d,t]);function re(f){let y=l.current;if(!y)return {x:0,y:0};let k=y.getBoundingClientRect(),T=y.width/Math.max(k.width,1),V=y.height/Math.max(k.height,1);return {x:(f.clientX-k.left)*T,y:(f.clientY-k.top)*V}}function _(){M.current||(M.current=true,requestAnimationFrame(()=>{M.current=false;let f=l.current;f&&dt(f,h,g.current);}));}function Ce(f){if(f.button!==void 0&&f.button!==0)return;if(n==="comment"){let k=l.current;if(!k)return;let T=k.getBoundingClientRect(),V=Cn((f.clientX-T.left)/Math.max(T.width,1),.72),K=Cn((f.clientY-T.top)/Math.max(T.height,1),.8),j=++C.current;b(F=>[...F,{id:j,x:V,y:K,text:"",color:r}]),I.current.push("comment"),A.current=j;return}try{f.currentTarget.setPointerCapture(f.pointerId);}catch{}S.current=true,a?.(true);let y=re(f);n==="arrow"?g.current={kind:"arrow",from:y,to:y,color:r,width:o}:n==="rect"?g.current={kind:"rect",from:y,to:y,color:r,width:o}:g.current={kind:"freehand",points:[y],color:r,width:o},x.current=performance.now(),_();}function he(f){if(!S.current||!g.current)return;let y=re(f),k=g.current;if(k.kind==="arrow"||k.kind==="rect")k.to=y;else {let T=k.points[k.points.length-1],V=T?(T.x-y.x)**2+(T.y-y.y)**2:1/0,K=performance.now(),j=K-x.current;(V>16||j>16)&&(k.points.push(y),x.current=K);}_();}function H(){if(!S.current)return;S.current=false,a?.(false);let f=g.current;if(g.current=null,!!f){if(f.kind==="arrow"||f.kind==="rect"){let y=f.to.x-f.from.x,k=f.to.y-f.from.y;if(y*y+k*k<16){let T=l.current;T&&dt(T,h,null);return}}else if(f.points.length<2){let y=l.current;y&&dt(y,h,null);return}w(y=>[...y,f].slice(-50)),I.current.push("anno");}}return jsxRuntime.jsxs("div",{ref:u,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:s}),jsxRuntime.jsx("canvas",{ref:l,className:"lumen-annotate-overlay",onPointerDown:Ce,onPointerMove:he,onPointerUp:H,onPointerCancel:H}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:L.map(f=>jsxRuntime.jsx(Ro,{comment:f,onChange:q,onRemove:D},f.id))})]})});function Ro({comment:e,onChange:t,onRemove:n}){let r=Rn.useRef(null);return Rn.useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxRuntime.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:[jsxRuntime.jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsxRuntime.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??"")}),jsxRuntime.jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function dt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)Nt(r,o);n&&Nt(r,n);}}function Nt(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")So(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 So(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],s=(a.x+i.x)/2,l=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,s,l);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function xo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,s=14*o,l=10*o,u=12*o,d=s*1.35,p=l*1.7,h=t.x*n,w=t.y*r,g=Math.min(n*.6,n-h-8*o);e.save(),e.font=`500 ${s}px ${At}`,e.textBaseline="top";let S=ko(e,a,g-i*2),x=S.reduce((A,q)=>Math.max(A,e.measureText(q).width),0),M=Math.min(g,Math.max(x,56*o)+i*2),L=i*2+p+S.length*d;Mo(e,h,w,M,L,u),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let b=h+18*o,C=w+L;e.beginPath(),e.moveTo(b,C-o),e.lineTo(b+13*o,C-o),e.lineTo(b+4*o,C+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${l}px ${At}`,e.fillText("COMMENT",h+i,w+i),e.fillStyle="#111318",e.font=`500 ${s}px ${At}`;let I=w+i+p;for(let A of S)e.fillText(A,h+i,I),I+=d;e.restore();}function ko(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let s=a?`${a} ${i}`:i;a&&e.measureText(s).width>n?(o.push(a),a=i):a=s;}return a&&o.push(a),o.length?o:[t]}function Mo(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.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 Qe({children:e,...t}){return jsxRuntime.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 Lo(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.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"}),jsxRuntime.jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function To(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsxRuntime.jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Po(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsxRuntime.jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function mt(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function kn(e){return jsxRuntime.jsxs(Qe,{...e,children:[jsxRuntime.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var It={shot:Lo,video:To,upload:Po};function Mn(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 Ao(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 No=4e3;async function Dt(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((l,u)=>{if(n.readyState>=2)return l();n.addEventListener("loadeddata",()=>l(),{once:true}),n.addEventListener("error",()=>u(new Error("video decode failed")),{once:true});}),await Ao(n,Math.min(.1,(n.duration||0)/2));let i=await Mn(n),s=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:s}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),No);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Ot(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 Mn(t)}catch{return null}finally{t.srcObject=null;}}async function Bt(){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 _t=60,Io=25*1024*1024,Ln=[{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)"}],Tn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],Pn=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],An=[{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 Ht(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:s,consumePendingVideo:l,canRecordScreen:u,consumeRecordStartError:d,startScreenCaptureSession:p,consumePendingScreenshot:h,isolateEvents:w,keyboardInset:g}=Ge(),[S,x]=Rn.useState(1),[M,L]=Rn.useState(null),[b,C]=Rn.useState({kind:"idle"}),[I,A]=Rn.useState(false),[q,D]=Rn.useState(0),[re,_]=Rn.useState(null),[Ce,he]=Rn.useState(false),[H,f]=Rn.useState("arrow"),[y,k]=Rn.useState(Ln[0].value),[T,V]=Rn.useState(Tn[1].value),[K,j]=Rn.useState(""),[F,oe]=Rn.useState("bug"),[Re,nt]=Rn.useState(r?.email??""),[W,Ie]=Rn.useState(null),[X,J]=Rn.useState(null),[de,Se]=Rn.useState(0),[ae,Q]=Rn.useState(null),[me,Y]=Rn.useState(null),[ee,Fe]=Rn.useState(false),pe=Rn.useRef(null),xe=Rn.useRef(null),Ue=Rn.useRef(null),ze=Rn.useRef(null),be=Xe(t,g),ie=Rn.useRef(false),De=Rn.useRef(false);Rn.useEffect(()=>{t||(De.current=false);},[t]),Rn.useEffect(()=>{if(!t)return;if(De.current){ie.current=false;return}De.current=true,ie.current=false,x(1),L(null),j(""),J(null),Se(0),Q(null),A(false),D(0),_(null),he(false),Y(null);let c=h();if(c){L("shot"),Oe(c),C({kind:"ready",capture:c});return}let v=l();if(v)L("video"),Q({blob:v.blob,durationMs:v.durationMs}),v.blob.size>Io&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),v.poster?C({kind:"ready",capture:qe(v.poster,["Screen recording; preview is the first frame."])}):(C({kind:"capturing"}),(async()=>{let P=null;if(v.deriveBlobPoster)try{P=(await Dt(v.blob)).poster;}catch{P=null;}P=P??await Bt(),!ie.current&&C(P?{kind:"ready",capture:qe(P,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let P=d();P?(L("video"),Y(P),C({kind:"idle"})):a?(L("shot"),C({kind:"ready",capture:a})):o?.mode==="manual"?C({kind:"manual"}):o?.provider&&!i?(L("shot"),ve(o.mode??"auto")):C({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ie.current=true;}},[t,o,a,i]),Rn.useEffect(()=>{if(!t)return;ze.current=document.activeElement??null;let c=document.documentElement,v=c.style.overflow,P=c.style.paddingRight,Z=window.innerWidth-c.clientWidth;c.style.overflow="hidden",Z>0&&(c.style.paddingRight=`${Z}px`);let te=false,Me=()=>{if(!te){te=true,c.style.overflow=v,c.style.paddingRight=P;try{ze.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Me),()=>{window.removeEventListener("pagehide",Me),Me();}},[t]),Rn.useEffect(()=>{if(!t)return;function c(v){if(v.key==="Escape"){v.preventDefault(),n();return}if(v.key!=="Tab")return;let P=xe.current;if(!P)return;let Z=Ko(P);if(Z.length===0)return;let te=Z[0],Me=Z[Z.length-1],yt=document.activeElement;v.shiftKey&&(yt===te||!P.contains(yt))?(v.preventDefault(),Me.focus()):!v.shiftKey&&yt===Me&&(v.preventDefault(),te.focus());}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,n]),Rn.useEffect(()=>{if(!t||!w)return;let c=Ue.current;if(!c)return;let v=P=>{P.target===c&&P.stopPropagation();};return c.addEventListener("pointerdown",v),c.addEventListener("click",v),c.addEventListener("touchstart",v,{passive:true}),()=>{c.removeEventListener("pointerdown",v),c.removeEventListener("click",v),c.removeEventListener("touchstart",v);}},[t,w]),Rn.useEffect(()=>{if(!t||!be.open)return;let c=xe.current,v=document.activeElement;if(c&&v&&c.contains(v))try{v.scrollIntoView({block:"center"});}catch{}},[t,be.open,be.inset]),Rn.useEffect(()=>{if(!t||b.kind!=="manual")return;function c(v){let te=Array.from(v.clipboardData?.items??[]).find(Me=>Me.type.startsWith("image/"))?.getAsFile();te&&(v.preventDefault(),G(te));}return window.addEventListener("paste",c),()=>window.removeEventListener("paste",c)},[t,b.kind]),Rn.useEffect(()=>{if(!W)return;let c=Date.now(),v=window.setInterval(()=>{let P=Math.floor((Date.now()-c)/1e3);Se(P),P>=_t&&ye();},250);return ()=>window.clearInterval(v)},[W]);let ke=Rn.useRef(null);if(ke.current=W,Rn.useEffect(()=>{t||ke.current&&(ke.current.cancel(),ke.current=null,Ie(null),Se(0));},[t]),Rn.useEffect(()=>()=>{ke.current?.cancel();},[]),!t)return null;async function ve(c){ie.current=false,C({kind:"capturing"});try{let v=await lt({...o,mode:c,target:o?.target??document.documentElement});return ie.current?!1:(Oe(v),C({kind:"ready",capture:v}),!0)}catch(v){return ie.current||C({kind:"manual",error:v instanceof Error?v.message:"Automatic screenshot capture was unavailable."}),false}}async function fe(c){L(c),Y(null),_(null),c!=="video"&&Be(),c==="shot"?await ve(o?.mode??"auto"):c==="video"?(Q(null),C({kind:"idle"})):C({kind:"manual"});}async function G(c){if(c.type.startsWith("image/")){Be();let v=qe(c,["Manual image upload used."]);C({kind:"ready",capture:v});return}if(c.type.startsWith("video/")){C({kind:"capturing"});try{let{poster:v,durationMs:P}=await Dt(c),Z=v??await Bt();if(!Z){C({kind:"manual",error:"Could not read that video."});return}let te=qe(Z,["Uploaded video; preview is the first frame."]);Q({blob:c,durationMs:P}),C({kind:"ready",capture:te});}catch{C({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function Oe(c){c.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function we(){try{let c=await hn(_t);Ie(c);}catch(c){sonner.toast.error(c instanceof Error?c.message:"Microphone unavailable");}}async function ye(){if(W)try{let c=await W.stop();J({blob:c.blob,durationMs:c.durationMs});}catch(c){sonner.toast.error(c instanceof Error?c.message:"Could not stop recording");}finally{Ie(null);}}function Ke(){W?.cancel(),Ie(null),J(null),Se(0);}function We(c){let v=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!W&&!X?jsxRuntime.jsxs("button",{type:"button",onClick:we,className:c==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(kn,{}),"Record voice note"]}):null,W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(Ho,{stream:W.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[de,"s / ",_t,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:ye,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:Ke,className:"lumen-btn-ghost",children:"Cancel"})]}):null,X&&!W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Fo,{blob:X.blob,durationMs:X.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>J(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return c==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[v,!W&&!X?jsxRuntime.jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),v]})}async function rt(){Y(null);try{await s();}catch(c){sonner.toast.error(c instanceof Error?c.message:"Screen capture unavailable");}}function Be(){Q(null);}let ot=b.kind==="ready";async function _e(){if(W&&await ye(),S===1){if(b.kind==="ready"){let c=await pe.current?.flatten();_(c??b.capture.blob),he(c!=null&&c!==b.capture.blob);}x(2);}else S===2?x(3):await vt();}function bt(){S>1&&x(c=>c-1);}async function vt(){if(b.kind!=="ready")return;let c=K.trim(),{capture:v}=b;A(true),D(0);try{let P=re??v.blob,Z=await e.submit({rawText:c.length>0?c:void 0,category:F,submitterEmail:Re.trim()||void 0,screenshot:P,audio:X?.blob,audioDurationMs:X?.durationMs,video:ae?.blob,videoDurationMs:ae?.durationMs,context:gn(v)},{onUploadProgress:te=>D(Math.min(.95,te))});D(1),sonner.toast.success("Feedback sent \u2014 thank you."),Z.id,n();}catch(P){sonner.toast.error(P instanceof Error?P.message:"Could not submit feedback"),A(false);}}function ge(c){c.target===c.currentTarget&&!I&&n();}let R=Math.round(q*100),O=M==="video",U=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,wt=M==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&U,gr=S===1&&!ot||I,hr=S<3?"Next":I?R<95?`Uploading ${R}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:Ue,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:be.inset?{"--lumen-keyboard-inset":`${be.inset}px`}:void 0,onMouseDown:ge,children:jsxRuntime.jsxs("div",{ref:xe,className:"lumen-modal","data-lumen-drawing":ee?"true":void 0,children:[jsxRuntime.jsx(_o,{onDismiss:n}),jsxRuntime.jsxs("header",{className:"lumen-modal-header",children:[jsxRuntime.jsxs("h2",{className:"lumen-modal-title",children:[jsxRuntime.jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsx(Do,{step:S}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[S===1?jsxRuntime.jsx("div",{className:"lumen-pane",children:M===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(c.primary?" lumen-method-primary":""),onClick:()=>fe(c.value),disabled:b.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(v,{})}),c.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]})]},c.value)})}),jsxRuntime.jsx("p",{className:"lumen-status lumen-method-help",children:"Choose how to capture your feedback."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method-switch",role:"group","aria-label":"Switch capture method",children:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button","aria-pressed":M===c.value,onClick:()=>fe(c.value),disabled:b.kind==="capturing",children:[jsxRuntime.jsx(v,{}),c.label]},c.value)})}),M==="video"&&b.kind==="idle"?jsxRuntime.jsx(Oo,{canRecord:u,onRecord:rt,onUpload:()=>fe("upload"),error:me}):null,b.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,b.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:M==="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."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:M==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:M==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:c=>{let v=c.currentTarget.files?.[0];v&&G(v),c.currentTarget.value="";}})]})]}):null,b.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[O?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(pt,{label:"Arrow",active:H==="arrow",onClick:()=>f("arrow")}),jsxRuntime.jsx(pt,{label:"Box",active:H==="rect",onClick:()=>f("rect")}),jsxRuntime.jsx(pt,{label:"Draw",active:H==="freehand",onClick:()=>f("freehand")}),jsxRuntime.jsx(pt,{label:"Comment",active:H==="comment",onClick:()=>f("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:Ln.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:c.value},"aria-label":c.label,"aria-pressed":y===c.value,onClick:()=>k(c.value)},c.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Tn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":c.label,"aria-pressed":T===c.value,onClick:()=>V(c.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:c.dot,height:c.dot}})},c.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.undo(),children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.reset(),children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Sn,{ref:pe,screenshot:b.capture.blob,tool:H,color:y,strokeWidth:T,onDrawingChange:Fe})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>M&&fe(M),children:O?"\u21BB Re-record":"\u21BB Recapture"}),wt?jsxRuntime.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:[jsxRuntime.jsx(mt,{})," Capture exact screen"]}):null,O?ae?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ae.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:b.capture.method==="web-display-media"?"Exact screen captured":`${Nn(M)} captured \xB7 switch method above anytime`})]}),We("capture")]}):null]})}):null,S===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:K,onChange:c=>j(c.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),We("describe"),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:Pn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":F===c.value,onClick:()=>oe(c.value),children:c.label},c.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:Re,onChange:c=>nt(c.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,S===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[Nn(M),Ce?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:Pn.find(c=>c.value===F)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[K.trim()?K.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[X?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(X.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>J(null),children:"\xD7"})]}):null,ae?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ae.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Be,children:"\xD7"})]}):null,Re.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",Re.trim()]}):null,!X&&!W?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{x(2),we();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[I?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":R,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${R}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:S===1?n:bt,className:"lumen-btn-ghost",disabled:I,children:S===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:_e,className:"lumen-btn-primary",disabled:gr,children:hr})]})]})]})})}function Nn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function Do({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsxRuntime.jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxRuntime.jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsxRuntime.jsx("span",{className:"lumen-step-num",children:n.n}),jsxRuntime.jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function Oo({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[r?jsxRuntime.jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsxRuntime.jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsxRuntime.jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxRuntime.jsxs("div",{className:"lumen-record-copy",children:[jsxRuntime.jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsxRuntime.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."})]})]}):jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[jsxRuntime.jsx("p",{className:"lumen-record-unavailable",children:Bo()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function Bo(){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 pt({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function _o({onDismiss:e}){let t=Rn.useRef(null),n=Rn.useRef(0),r=Rn.useRef(null);function o(s){s.currentTarget.setPointerCapture(s.pointerId),t.current=s.clientY,n.current=performance.now(),r.current=s.currentTarget.parentElement;}function a(s){if(t.current==null||!r.current)return;let l=Math.max(0,s.clientY-t.current);r.current.style.transform=`translateY(${l}px)`;}function i(s){if(t.current==null||!r.current)return;let l=Math.max(0,s.clientY-t.current),u=Math.max(1,performance.now()-n.current),d=l/u;r.current.style.transform="",r.current.style.transition="",t.current=null,(l>80||d>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function Ho({stream:e}){let t=Rn.useRef(null);return Rn.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 s=window.AudioContext??window.webkitAudioContext;if(!s)return;let l=new s,u=l.createMediaStreamSource(e),d=l.createAnalyser();d.fftSize=1024,d.smoothingTimeConstant=.6,u.connect(d);let p=new Uint8Array(d.fftSize),h=18,w=3,g=3,S=Math.max(2,(o-w*(h-1))/h),x=Math.min(S/2,3),M=new Array(h).fill(0),L=0,b=false;function C(){if(b)return;d.getByteTimeDomainData(p);let I=Math.floor(p.length/h);i.clearRect(0,0,o,a),i.fillStyle=Uo("--lumen-danger")||"rgb(239,68,68)";for(let A=0;A<h;A++){let q=0;for(let H=0;H<I;H++){let f=Math.abs((p[A*I+H]??128)-128);f>q&&(q=f);}let D=Math.min(1,q/128*1.8),re=M[A]??0;M[A]=D>re?D:re+(D-re)*.35;let _=Math.max(g,M[A]*a),Ce=A*(S+w),he=(a-_)/2;Vo(i,Ce,he,S,_,x),i.fill();}L=requestAnimationFrame(C);}return L=requestAnimationFrame(C),()=>{b=true,cancelAnimationFrame(L);try{u.disconnect();}catch{}l.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function Vo(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.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 Fo({blob:e,durationMs:t}){let[n,r]=Rn.useState("");return Rn.useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxRuntime.jsxs("div",{className:"lumen-audio-preview",children:[jsxRuntime.jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxRuntime.jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function Uo(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var zo='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ko(e){return Array.from(e.querySelectorAll(zo)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var ft=class extends Rn__namespace.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t){if(typeof document<"u"){let n=document.documentElement;n.style.overflow="",n.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),sonner.toast.error("Feedback widget hit a snag and was reset. Please try again."),Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function _n({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx($o,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):reactDom.createPortal(jsxRuntime.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:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function $o({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(0);Rn.useEffect(()=>{let s=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));s();let l=window.setInterval(s,250);return ()=>window.clearInterval(l)},[e,t]);let i=s=>`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`;return jsxRuntime.jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxRuntime.jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxRuntime.jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function Hn({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,s=e.phase==="grabbing";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-cap-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[s?jsxRuntime.jsx("span",{className:"lumen-cap-hud-spinner","aria-hidden":"true"}):jsxRuntime.jsx("span",{className:"lumen-cap-hud-ico","aria-hidden":"true",children:jsxRuntime.jsx(mt,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:s?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:s,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:s,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Vt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function Vn(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function Fn(e){return e instanceof Error?e:new Error(String(e))}function Un(e,t,n){let r=false,o=false,a=false,i=null;function s(){o||(o=true,n.onCancelled());}function l(d){o||(o=true,n.onResult(d));}function u(d){o||(o=true,n.onError(d));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(d=>{if(i=d,r){try{d.cancel();}catch{}s();return}if(n.onActive(d),a){n.onProcessing();try{d.stop();}catch{}}Promise.resolve(d.result).then(p=>{r?s():l(p);}).catch(p=>{r||Vn(p)?s():u(Fn(p));});}).catch(d=>{r||Vn(d)?s():u(Fn(d));}),{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{}s();}}}}function zn(){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 s=document.elementsFromPoint(i,n);for(let l of s){if(o.has(l))continue;o.add(l);let u=window.getComputedStyle(l);if(u.position!=="fixed"&&u.position!=="sticky")continue;let d=l.getBoundingClientRect();d.bottom<t-8||d.bottom>t+8||d.width<e*.6||d.height>a&&(a=d.height);}}return a}function Ft(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 s of Array.from(i)){let l=s.getBoundingClientRect();if(l.height===0||l.width===0)continue;let u=0;switch(t){case "bottom":if(l.bottom<r-8)break;u=Math.max(0,r-l.top);break;case "top":if(l.top>8)break;u=Math.max(0,l.bottom);break;case "left":if(l.left>8)break;u=Math.max(0,l.right);break;case "right":if(l.right<n-8)break;u=Math.max(0,n-l.left);break}u>o&&(o=u);}}return o}function Kn(e){let[t,n]=Rn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Rn.useRef(t),o=Qo(e.avoid),a=e.placement,i=e.offset.x,s=e.offset.y;return Rn.useEffect(()=>{if(typeof window>"u")return;let l=0,u=false,d=()=>{if(l=0,u)return;let S=a[0]==="b"?"bottom":"top",x=a[1]==="r"?"right":"left",M=0,L=0;e.avoid==="auto"&&S==="bottom"?M=zn():Array.isArray(e.avoid)&&(M=Ft(e.avoid,S),L=Ft(e.avoid,x));let b={bottom:S==="bottom"?s+M:0,top:S==="top"?s+M:0,right:x==="right"?i+L:0,left:x==="left"?i+L:0},C=r.current;(b.bottom!==C.bottom||b.top!==C.top||b.right!==C.right||b.left!==C.left)&&(r.current=b,n(b));},p=()=>{l||(l=window.requestAnimationFrame(d));};p();let h=typeof ResizeObserver<"u"?new ResizeObserver(p):null;h?.observe(document.documentElement);let w=typeof MutationObserver<"u"?new MutationObserver(p):null;w?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let g=window.visualViewport;return g?.addEventListener("resize",p),g?.addEventListener("scroll",p),()=>{u=true,l&&window.cancelAnimationFrame(l),h?.disconnect(),w?.disconnect(),window.removeEventListener("resize",p),g?.removeEventListener("resize",p),g?.removeEventListener("scroll",p);}},[a,i,s,o]),t}function Qo(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var Wn=["mousedown","touchstart"];function Ve(e){let t=Rn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Rn.useRef(e.onClick);n.current=e.onClick;let r=Rn.useRef(e.isolate??true);r.current=e.isolate??true;let o=Rn.useRef(null);return Rn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=u=>{r.current&&u.stopPropagation(),t.current?.(u);},s=u=>{r.current&&u.stopPropagation(),n.current(u);},l=u=>{r.current&&u.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",s);for(let u of Wn)a.addEventListener(u,l,u==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",s);for(let u of Wn)a.removeEventListener(u,l);};},[])}function Yn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[s,l]=Rn.useState(null),u=Rn.useRef(null),d=Kn(e),p=Xe(e.keyboard!=="off",i),h=Ve({onPointerDown:r,onClick:o,isolate:a}),w=Rn.useCallback(D=>{u.current=D,h(D);},[h]);Rn.useEffect(()=>{typeof document>"u"||l(t??document.body);},[t]);let g=e.placement,S=g[0]==="b"?"bottom":"top",x=g[1]==="r"?"right":"left",M=S==="bottom",L=p.open&&M&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,b=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&M&&p.inset<=0);if(oa(u,!n&&!b),!s)return null;let C=S==="bottom"?d.bottom:d.top,I=x==="right"?d.right:d.left,A=n||b,q={position:"fixed",[S]:e.safeArea?`calc(${C}px + env(safe-area-inset-${S}, 0px))`:`${C}px`,[x]:e.safeArea?`calc(${I}px + env(safe-area-inset-${x}, 0px))`:`${I}px`,zIndex:e.zIndex,transform:L?`translateY(-${L}px)`:void 0,opacity:A?0:1,pointerEvents:A?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:w,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:q,"aria-label":e.label,"aria-hidden":A?true:void 0,tabIndex:A?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),s)}function oa(e,t){let n=Rn.useRef(false);Rn.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,s=a.top+a.height/2,l=document.elementsFromPoint(i,s),u=$n(window.getComputedStyle(o).zIndex);for(let d of l){if(d===o||o.contains(d))continue;if($n(window.getComputedStyle(d).zIndex)>u){n.current=true,console.warn("[lumen] trigger is occluded by",d);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function $n(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function Gn({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),l=Ve({onPointerDown:r,onClick:o,isolate:a});return Rn.useEffect(()=>{if(typeof document>"u")return;let u=e instanceof HTMLElement?e:e.current??null;s(u);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:l,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),i):null}function Jn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),[l,u]=Rn.useState(false),d=Rn.useRef(null),p=Ve({onPointerDown:x=>{r?.(x),d.current={x:x.clientX,y:x.clientY},u(true);let M=x.currentTarget;try{M?.setPointerCapture?.(x.pointerId);}catch{}},onClick:o,isolate:a});if(Rn.useEffect(()=>{typeof document>"u"||s(t??document.body);},[t]),!i)return null;let h=`lumen-notch lumen-notch-${e.edge}${l?" lumen-notch-expanded":""}`;function w(x){let M=d.current;if(!M)return;let L=x.clientX-M.x,b=x.clientY-M.y;(e.edge==="top"&&b>16||e.edge==="bottom"&&b<-16||e.edge==="right"&&L<-16||e.edge==="left"&&L>16)&&(d.current=null,o(x.nativeEvent));}function g(){d.current=null,u(false);}function S(){d.current=null,u(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:h,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:w,onPointerUp:g,onPointerCancel:S,onMouseEnter:()=>u(true),onMouseLeave:()=>u(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function Qn(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function ha(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function er(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:ha(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var wa={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function tr(e){let t=Rn.useId();Rn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${ya(t)}`,o={},a=(i,s)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,s);};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,s]of Object.entries(wa)){let l=e[s];typeof l=="string"&&l.length>0&&a(i,l);}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,s]of Object.entries(o))i.startsWith("--")?s?n.style.setProperty(i,s):n.style.removeProperty(i):s==null?n.removeAttribute(i):n.setAttribute(i,s);}},[e,t]);}function ya(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var nr=Symbol.for("lumen.history.patched"),Ut="lumen:locationchange";function Ra(){if(typeof window>"u")return;let e=window;if(e[nr])return;e[nr]=true;let t=()=>window.dispatchEvent(new Event(Ut)),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]=Rn.useState(false);return Rn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;Ra();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Ut,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Ut,r),window.removeEventListener("popstate",r);}},[e]),t}var ka=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function or(){let[e,t]=Rn.useState(false);return Rn.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||"";ka.some(a=>o.includes(a))&&t(true);},[]),e}var ir="lumen.config.v1.",Ta=3600*1e3;function sr(e,t){let[n,r]=Rn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Rn.useEffect(()=>{if(typeof window>"u")return;let o=Oa(e);o&&r({trigger:o.trigger,enabled:ar(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),s=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(s,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);let u=await l.json(),d=lr(u.trigger);if(!d)throw new Error("Malformed config response");let p=Na(u.trigger),h=ur(u.brand);Ba(e,d,p,h),r({trigger:d,enabled:ar(d),shakeToOpen:p,brand:h,loading:false});}).catch(()=>{r(l=>l.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:l);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function ar(e){return e.kind!=="headless"}var Pa=["br","bl","tr","tl"],Aa=["top","right","bottom","left"];function lr(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:Pa.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:Aa.find(o=>o===t.edge)??"top",label:n}:null}function Na(e){return !e||typeof e!="object"?false:e.shake===true}var Ia=/^#[0-9a-fA-F]{6}$/,Da=["auto","light","dark"];function ur(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&Ia.test(t.accent)?t.accent:null;if(!n)return null;let r=Da.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 Oa(e){try{let t=window.localStorage.getItem(ir+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>Ta)return null;let r=lr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:ur(n.brand)}:null}catch{return null}}function Ba(e,t,n,r){try{window.localStorage.setItem(ir+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function Ha(e){if(e&&typeof e=="object")return e.type===ct;if(typeof e=="string")try{return JSON.parse(e).type===ct}catch{return false}return false}function Va(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(s,l,u,d){if(!a)return a={x:s,y:l,z:u,t:d},false;if(d-a.t<o)return false;let p=Math.abs(s-a.x)+Math.abs(l-a.y)+Math.abs(u-a.z);return a={x:s,y:l,z:u,t:d},p<t?false:(i=i.filter(h=>d-h<r),i.push(d),i.length>=n?(i=[],true):false)}}}function cr(e,t,n){Rn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let d=Date.now();n||d-r<o||(r=d,t());}let i=d=>{Ha(d.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let s=Va(),l=d=>{let p=d.accelerationIncludingGravity??d.acceleration;!p||p.x==null||p.y==null||p.z==null||s.push(p.x,p.y,p.z,Date.now())&&a();},u=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return u&&window.addEventListener("devicemotion",l),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),u&&window.removeEventListener("devicemotion",l);}},[e,t,n]);}var mr="https://shakebugs.vercel.app",ht=60;function pr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function za({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:s,portalTarget:l,capture:u,record:d,shakeToOpen:p,onOpenChange:h,beforeOpen:w,onTriggerActivate:g,isolateEvents:S=true,keyboardInset:x,suppressTrigger:M=false,children:L}){let[b,C]=Rn.useState(false),[I,A]=Rn.useState(false),[q,D]=Rn.useState(null),[re,_]=Rn.useState(null),[Ce]=Rn.useState(false),[he]=Rn.useState(null),H=Rn.useRef(false),f=Rn.useRef(false),y=Rn.useRef(null),k=Rn.useMemo(()=>new en({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Rn.useEffect(()=>{pn({ignoreUrlPrefix:(t??mr).replace(/\/$/,"")});},[t]);let T=Rn.useRef(h);T.current=h,Rn.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 V=Rn.useRef(null);Rn.useEffect(()=>{if(V.current===b)return;let R=V.current;V.current=b,R!==null&&T.current?.(b);},[b]);let K=Rn.useRef(w);K.current=w;let j=Rn.useRef(g);j.current=g;let F=Rn.useCallback(R=>{f.current=true,y.current=Promise.resolve().then(()=>K.current?.(R)).then(()=>j.current?.(R)).then(()=>{});},[]),oe=Rn.useCallback(R=>{H.current||b||Y.current||we.current||(H.current=true,A(true),D(null),_(null),(async()=>{try{if(f.current?await y.current:(await K.current?.(R),await j.current?.(R)),u?.mode==="manual")D(null),_(null);else if(u?.provider)D(null),_(null);else {let O=await lt({...u,mode:u?.mode??"auto",target:u?.target??document.documentElement});D(O);}}catch(O){_(O instanceof Error?O:new Error(String(O)));}finally{f.current=false,y.current=null,H.current=false,A(false),C(true);}})());},[u,b]),Re=Rn.useCallback(()=>{C(false),D(null),_(null);},[]),nt=Rn.useCallback(k.submit.bind(k),[k]),[W,Ie]=Rn.useState(0),X=Rn.useCallback(()=>{H.current=false,A(false),C(false),D(null),_(null),Ie(R=>R+1);},[]),[J,de]=Rn.useState(null),[Se,ae]=Rn.useState(null),Q=Rn.useRef(null),me=Rn.useRef(null),Y=Rn.useRef(false),ee=Rn.useRef(null),Fe=Rn.useRef(null),pe=Rn.useRef(null),xe=Rn.useCallback((R,O=false)=>{if(Q.current=null,me.current=null,Y.current=false,de(null),!R){ee.current=null;return}Fe.current={blob:R.blob,durationMs:R.durationMs,poster:ee.current,deriveBlobPoster:O},ee.current=null,C(true);},[]);Rn.useEffect(()=>{if(!b)return;if(!d?.provider){ae(null);return}let R=d.isAvailable;if(!R){ae(true);return}let O=false;return Promise.resolve().then(()=>R()).then(U=>{O||ae(U);}).catch(()=>{O||ae(false);}),()=>{O=true;}},[b,d?.provider,d?.isAvailable]);let Ue=Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).canRecord,ze=Rn.useCallback(async()=>{if(Y.current)return;if(pe.current=null,Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).usingProvider&&d?.provider){Y.current=true,ee.current=null,C(false),me.current=Un(d.provider,{maxDurationSeconds:ht},{onStarting:()=>de({phase:"starting"}),onActive:U=>{de({phase:"recording",stream:U.stream??null,startedAt:Date.now(),maxSeconds:ht}),U.stream&&Ot(U.stream).then(wt=>{ee.current=wt;}).catch(()=>{});},onProcessing:()=>de({phase:"processing"}),onResult:U=>xe({blob:U.blob,durationMs:U.durationMs},true),onCancelled:()=>{me.current=null,Y.current=false,ee.current=null,de(null),D(null),_(null),C(true);},onError:U=>{me.current=null,Y.current=false,ee.current=null,de(null),pe.current=U.message||"Screen recording could not start.",C(true);}});return}if(Q.current)return;let O=await bn(ht);Q.current=O,Y.current=true,ee.current=null,de({phase:"recording",stream:O.stream,startedAt:Date.now(),maxSeconds:ht}),C(false),Ot(O.stream).then(U=>{ee.current=U;}).catch(()=>{}),O.result.then(U=>xe(U)).catch(()=>xe(null));},[xe,d?.provider,Se]),be=Rn.useCallback(()=>{me.current?me.current.stop():Q.current?.stop();},[]),ie=Rn.useCallback(()=>{if(me.current){me.current.cancel();return}let R=Q.current;Q.current=null,Y.current=false,ee.current=null,de(null),R?.cancel(),D(null),_(null),C(true);},[]),De=Rn.useCallback(()=>{let R=Fe.current;return Fe.current=null,R},[]),ke=Rn.useCallback(()=>{let R=pe.current;return pe.current=null,R},[]);Rn.useEffect(()=>{b||(pe.current=null);},[b]);let[ve,fe]=Rn.useState(null),G=Rn.useRef(null),Oe=Rn.useRef(null),we=Rn.useRef(false),ye=Rn.useCallback(()=>{let R=G.current;G.current=null,we.current=false,R?.stop(),fe(null),C(true);},[]),Ke=Rn.useCallback(()=>{let R=G.current;R&&(fe({phase:"grabbing"}),(async()=>{try{let O=await R.grab();if(G.current!==R)return;Oe.current=O,G.current=null,we.current=!1,R.stop(),fe(null),C(!0);}catch{if(G.current!==R)return;G.current=null,we.current=false,R.stop(),fe(null),sonner.toast.error("Could not capture the screen. Please try again."),C(true);}})());},[]),We=Rn.useCallback(async()=>{if(we.current)return;let R;try{R=await xt({...u});}catch{return}G.current=R,we.current=true,R.onEnded(()=>ye()),fe({phase:"live"}),C(false);},[u,ye]),rt=Rn.useCallback(()=>{let R=Oe.current;return Oe.current=null,R},[]);Rn.useEffect(()=>()=>{G.current?.stop(),G.current=null;},[]);let Be=or(),ot=rr(i),_e=sr(a?"":e,t??mr);tr(s??$a(_e.brand));let bt=p??_e.shakeToOpen;cr(bt,oe,b);let vt=Rn.useMemo(()=>({client:k,user:n,isOpen:b,isSubmitting:Ce,error:he,open:oe,close:Re,openCapture:oe,closeCapture:Re,submit:nt,isNativeShell:Be,capture:u,initialCapture:q,initialCaptureError:re,isOpening:I,startVideoSession:ze,stopVideoSession:be,cancelVideoSession:ie,recording:J,consumePendingVideo:De,canRecordScreen:Ue,consumeRecordStartError:ke,startScreenCaptureSession:We,grabScreenCaptureFrame:Ke,cancelScreenCaptureSession:ye,screenCapture:ve,consumePendingScreenshot:rt,isolateEvents:S,keyboardInset:x}),[k,n,b,Ce,he,oe,Re,nt,Be,u,q,re,ze,be,ie,J,De,Ue,ke,We,Ke,ye,ve,rt,I,S,x]),ge=Wa({explicit:a,remote:_e.trigger,remoteLoading:_e.loading,floatingButton:o});return jsxRuntime.jsxs(Tt.Provider,{value:vt,children:[L,jsxRuntime.jsxs(ft,{onReset:X,children:[ge?.kind==="floating"?jsxRuntime.jsx(Yn,{config:er(ge),portalTarget:l,hidden:ot||M||I||J!=null||ve!=null,onPointerDown:F,onClick:R=>oe(R),isolateEvents:S,keyboardInset:x}):null,ge?.kind==="notch"?jsxRuntime.jsx(Jn,{config:Qn(ge),portalTarget:l,hidden:ot||M||I||J!=null||ve!=null,onPointerDown:F,onClick:R=>oe(R),isolateEvents:S}):null,ge?.kind==="inline"?jsxRuntime.jsx(Gn,{mount:ge.mount,label:ge.label??"Feedback",icon:ge.icon,onPointerDown:F,onClick:R=>oe(R),isolateEvents:S}):null,ve?jsxRuntime.jsx(Hn,{state:ve,portalTarget:l,onCapture:Ke,onCancel:ye}):null,J?jsxRuntime.jsx(_n,{state:J,portalTarget:l,onStop:be,onCancel:ie}):null,jsxRuntime.jsx(Ht,{})]},W),jsxRuntime.jsx(Ka,{})]})}function Ka(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Wa(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function $a(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function qa({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=Ge(),s=["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 jsxRuntime.jsx("button",{type:"button",className:s,"data-lumen-trigger":"",onClick:l=>{o?.(l),l.defaultPrevented||i(l.nativeEvent);},...a,children:r})}
4
+ exports.CaptureModal=Ht;exports.FeedbackButton=qa;exports.LUMEN_KEYBOARD_CSS_VAR=Mt;exports.LUMEN_KEYBOARD_EVENT=Ye;exports.LUMEN_SHAKE_MESSAGE=ct;exports.LumenProvider=za;exports.createNativeCaptureProvider=ao;exports.isLumenEventTarget=eo;exports.isolateLumenEvents=to;exports.readLumenKeyboardInset=Lt;exports.setLumenKeyboardInset=go;exports.useKeyboardInset=Xe;exports.useLumen=Ge;//# sourceMappingURL=index.cjs.map
5
5
  //# sourceMappingURL=index.cjs.map