@opengovsg/confetti 0.3.0 → 0.3.2

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/build/index.js CHANGED
@@ -1 +1 @@
1
- import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,X as S,Y as C,Z as w,_ as T,a as E,b as D,c as ee,d as O,f as k,g as te,h as ne,i as re,j as A,k as ie,l as ae,m as oe,o as se,p as ce,q as le,r as ue,s as j,t as de,u as fe,v as pe,w as M,x as N,y as me,z as he}from"./ModalContainer-B2qSiAge.js";import{i as ge,r as _e,t as ve}from"./internals-pYkbsaWU.js";import{ErrorBoundary as ye}from"react-error-boundary";import P,{Suspense as be,createContext as F,forwardRef as I,lazy as xe,useCallback as L,useContext as Se,useEffect as R,useMemo as z,useRef as B,useState as V}from"react";import{useLocalStorage as Ce,useSessionStorage as we,useTimeout as Te}from"usehooks-ts";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import G from"clsx";import{flushSync as Ee}from"react-dom";function De(e){return e.issues[0]?.message??`Invalid input`}const K={rating:({scale:e},t)=>u({scale:e},t),"open-ended":({max:e},t)=>o({maxLength:e},t),"single-select":({editable:e},t)=>le({maxLength:e?.max},t),"multi-select":({editable:e,max:t},n)=>x({maxLength:e?.max,maxSelected:t},n),statement:(e,t)=>l(),"bug-report":(e,t)=>y({},t)},Oe=(e,t)=>{let n=e.type;switch(n){case`rating`:{let r=K[n];return r(e,t)}case`open-ended`:{let r=K[n];return r(e,t)}case`single-select`:{let r=K[n];return r(e,t)}case`multi-select`:{let r=K[n];return r(e,t)}case`statement`:{let r=K[n];return r(e,t)}case`bug-report`:{let r=K[n];return r(e,t)}default:throw Error(`Unsupported question type`)}},ke=({originalQuestions:e,answers:t,errors:n,pointer:r=-1})=>{if(!e)return{questions:[],currentIndex:-1};let i=e.sort((e,t)=>e.position-t.position).map(e=>{let t={...e},r=n[e.id];return r&&(t.error=r),{...t,visible:!1}});for(let e=0;e<i.length;e++){let n=i[e];if(!n)continue;let a=ge({index:e,questions:i,answers:t});n.visible=r===e||a}let a=i.findIndex((e,n)=>n>r&&e.visible&&t[e.id]===void 0);return a===-1&&(a=i.findLastIndex(e=>!!e.visible)),{questions:i,currentIndex:a}},Ae=({questions:e,answers:t})=>{let n=je({questions:e,answers:t});return Object.fromEntries(Object.entries(n).filter(([,e])=>e!==null))},je=({questions:e,answers:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Me=({questions:e,errors:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Ne=({current:e,shouldAutoSubmit:t,onFinished:n,children:r})=>{let{survey:i,submit:a}=s(),[o,c]=V({}),[l,u]=V({}),d=z(()=>ke({originalQuestions:i?.questions,answers:o,errors:l,pointer:e}),[i?.questions,o,l,e]),f=z(()=>!!d.questions.filter(({required:e,visible:t})=>!!e&&!!t).every(({id:e})=>o[e]!==void 0),[o,d.questions]),[p,m]=V(!1),h=L(({answers:e})=>{a({answers:e}).finally(()=>{n?.()})},[n,a]),g=L(()=>{h({answers:Ae({questions:d.questions,answers:o})}),m(!0)},[o,d.questions,h]),_=L(({question:n,answer:r})=>{let a=d.questions.at(n);if(!a)return{error:`Question index is invalid`};let s=Oe(a.properties,{required:a.required}).safeParse(r);if(!s.success){let e=De(s.error);return u(t=>{if(t[a.id]===e)return t;let n={...t};return n[a.id]=e,n}),c(e=>{if(!(a.id in e))return e;let t={...e};return delete t[a.id],t}),{error:e}}u(e=>{if(!e[a.id])return e;let t={...e};return delete t[a.id],t});let f=!a.required&&!r?null:r,p={...o};if(p[a.id]===f)return{next:ke({originalQuestions:i?.questions,answers:p,errors:l,pointer:e}).currentIndex};p[a.id]=f;let g=ke({originalQuestions:i?.questions,answers:p,errors:l,pointer:e});return p=je({questions:g.questions,answers:p}),c(p),u(Me({questions:g.questions,errors:l})),g.questions.filter(({visible:e})=>!!e).every(({id:e})=>p[e]!==void 0)&&t&&(h({answers:Ae({questions:g.questions,answers:p})}),m(!0)),{next:g.currentIndex}},[d.questions,o,i?.questions,l,t,e,h]);return d.questions.length===0?U(H,{}):U(`div`,{className:`confetti`,children:r({questions:d.questions,current:e??d.currentIndex,update:_,isCompleted:f,submit:g,isSubmitted:p,errors:l})})},Pe=({children:e,onFinished:t,shouldAutoSubmit:n,...r})=>U(ye,{fallback:U(H,{}),children:U(b,{...r,children:U(Ne,{shouldAutoSubmit:n,onFinished:t,children:e})})});function Fe(e,t,n){let i=r(e=>{n&&!e.defaultPrevented&&n(t)});R(()=>{let t=e?.current?.form;return t?.addEventListener(`reset`,i),()=>{t?.removeEventListener(`reset`,i)}},[e])}function Ie(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:a=`label`}=e;t=c(t);let o=c(),s={};n&&(r=r?`${o} ${r}`:o,s={id:o,htmlFor:a===`label`?t:void 0});let l=ie({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:s,fieldProps:l}}function Le(e){let{description:t,errorMessage:n,isInvalid:r,validationState:i}=e,{labelProps:o,fieldProps:s}=Ie(e),c=a([!!t,!!n,r,i]),l=a([!!t,!!n,r,i]);return s=A(s,{"aria-describedby":[c,l,e[`aria-describedby`]].filter(Boolean).join(` `)||void 0}),{labelProps:o,fieldProps:s,descriptionProps:{id:c},errorMessageProps:{id:l}}}function Re(e,t,n){let{validationBehavior:i,focus:a}=e;d(()=>{if(i===`native`&&n?.current&&!n.current.disabled){let e=t.realtimeValidation.isInvalid?t.realtimeValidation.validationErrors.join(` `)||`Invalid value.`:``;n.current.setCustomValidity(e),n.current.hasAttribute(`title`)||(n.current.title=``),t.realtimeValidation.isInvalid||t.updateValidation(Be(n.current))}});let o=B(!1),s=r(()=>{o.current||t.resetValidation()}),c=r(e=>{t.displayValidation.isInvalid||t.commitValidation();let r=n?.current?.form;!e.defaultPrevented&&n&&r&&Ve(r)===n.current&&(a?a():n.current?.focus(),te(`keyboard`)),e.preventDefault()}),l=r(()=>{t.commitValidation()});R(()=>{let e=n?.current;if(!e)return;let t=e.form,r=t?.reset;return t&&(t.reset=()=>{o.current=!window.event||window.event.type===`message`&&p(window.event)instanceof MessagePort,r?.call(t),o.current=!1}),e.addEventListener(`invalid`,c),e.addEventListener(`change`,l),t?.addEventListener(`reset`,s),()=>{e.removeEventListener(`invalid`,c),e.removeEventListener(`change`,l),t?.removeEventListener(`reset`,s),t&&(t.reset=r)}},[n,i])}function ze(e){let t=e.validity;return{badInput:t.badInput,customError:t.customError,patternMismatch:t.patternMismatch,rangeOverflow:t.rangeOverflow,rangeUnderflow:t.rangeUnderflow,stepMismatch:t.stepMismatch,tooLong:t.tooLong,tooShort:t.tooShort,typeMismatch:t.typeMismatch,valueMissing:t.valueMissing,valid:t.valid}}function Be(e){return{isInvalid:!e.validity.valid,validationDetails:ze(e),validationErrors:e.validationMessage?[e.validationMessage]:[]}}function Ve(e){for(let t=0;t<e.elements.length;t++){let n=e.elements[t];if(n.validity?.valid===!1)return n}return null}const He={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},Ue={...He,customError:!0,valid:!1},q={isInvalid:!1,validationDetails:He,validationErrors:[]},We=F({}),Ge=`__reactAriaFormValidationState`;function J(e){if(e[Ge]){let{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}=e[Ge];return{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}}return Ke(e)}function Ke(e){let{isInvalid:t,validationState:n,name:r,value:i,builtinValidation:a,validate:o,validationBehavior:s=`aria`}=e;n&&(t||=n===`invalid`);let c=t===void 0?null:{isInvalid:t,validationErrors:[],validationDetails:Ue},l=z(()=>!o||i==null?null:Ye(Je(o,i)),[o,i]);a?.validationDetails.valid&&(a=void 0);let u=Se(We),d=z(()=>r?Array.isArray(r)?r.flatMap(e=>qe(u[e])):qe(u[r]):[],[u,r]),[f,p]=V(u),[m,h]=V(!1);u!==f&&(p(u),h(!1));let g=z(()=>Ye(m?[]:d),[m,d]),_=B(q),[v,y]=V(q),b=B(q),x=()=>{if(!S)return;C(!1);let e=l||a||_.current;Xe(e,b.current)||(b.current=e,y(e))},[S,C]=V(!1);return R(x),{realtimeValidation:c||g||l||a||q,displayValidation:s===`native`?c||g||v:c||g||l||a||v,updateValidation(e){s===`aria`&&!Xe(v,e)?y(e):_.current=e},resetValidation(){let e=q;Xe(e,b.current)||(b.current=e,y(e)),s===`native`&&C(!1),h(!0)},commitValidation(){s===`native`&&C(!0),h(!0)}}}function qe(e){return e?Array.isArray(e)?e:[e]:[]}function Je(e,t){if(typeof e==`function`){let n=e(t);if(n&&typeof n!=`boolean`)return qe(n)}return[]}function Ye(e){return e.length?{isInvalid:!0,validationErrors:e,validationDetails:Ue}:null}function Xe(e,t){return e===t?!0:!!e&&!!t&&e.isInvalid===t.isInvalid&&e.validationErrors.length===t.validationErrors.length&&e.validationErrors.every((e,n)=>e===t.validationErrors[n])&&Object.entries(e.validationDetails).every(([e,n])=>t.validationDetails[e]===n)}function Ze(...e){let t=new Set,n=!1,r={...He};for(let i of e){for(let e of i.validationErrors)t.add(e);for(let e in n||=i.isInvalid,r)r[e]||=i.validationDetails[e]}return r.valid=!n,{isInvalid:n,validationErrors:[...t],validationDetails:r}}function Qe(t,n){let{inputElementType:r=`input`,isDisabled:i=!1,isRequired:a=!1,isReadOnly:o=!1,type:s=`text`,validationBehavior:c=`aria`}=t,[l,u]=ce(t.value,t.defaultValue||``,t.onChange),{focusableProps:d}=oe(t,n),f=J({...t,value:l}),{isInvalid:m,validationErrors:h,validationDetails:g}=f.displayValidation,{labelProps:_,fieldProps:v,descriptionProps:y,errorMessageProps:b}=Le({...t,isInvalid:m,errorMessage:t.errorMessage||h}),x=e(t,{labelable:!0}),S={type:s,pattern:t.pattern},[C]=V(l);return Fe(n,t.defaultValue??C,u),Re(t,f,n),{labelProps:_,inputProps:A(x,r===`input`?S:void 0,{disabled:i,readOnly:o,required:a&&c===`native`,"aria-required":a&&c===`aria`||void 0,"aria-invalid":m||void 0,"aria-errormessage":t[`aria-errormessage`],"aria-activedescendant":t[`aria-activedescendant`],"aria-autocomplete":t[`aria-autocomplete`],"aria-haspopup":t[`aria-haspopup`],"aria-controls":t[`aria-controls`],value:l,onChange:e=>u(p(e).value),autoComplete:t.autoComplete,autoCapitalize:t.autoCapitalize,maxLength:t.maxLength,minLength:t.minLength,name:t.name,form:t.form,placeholder:t.placeholder,inputMode:t.inputMode,autoCorrect:t.autoCorrect,spellCheck:t.spellCheck,[parseInt(P.version,10)>=17?`enterKeyHint`:`enterkeyhint`]:t.enterKeyHint,onCopy:t.onCopy,onCut:t.onCut,onPaste:t.onPaste,onCompositionEnd:t.onCompositionEnd,onCompositionStart:t.onCompositionStart,onCompositionUpdate:t.onCompositionUpdate,onSelect:t.onSelect,onBeforeInput:t.onBeforeInput,onInput:t.onInput,...d,...v}),descriptionProps:y,errorMessageProps:b,isInvalid:m,validationErrors:h,validationDetails:g}}function $e(t,n,r){let{isDisabled:i=!1,isReadOnly:a=!1,value:o,name:s,form:c,children:l,"aria-label":u,"aria-labelledby":d,validationState:f=`valid`,isInvalid:m,onPressStart:h,onPressEnd:g,onPressChange:_,onPress:v,onPressUp:y,onClick:b}=t,x=e=>{e.stopPropagation(),n.setSelected(p(e).checked)},{pressProps:S,isPressed:C}=T({onPressStart:h,onPressEnd:g,onPressChange:_,onPress:v,onPressUp:y,onClick:b,isDisabled:i}),{pressProps:w,isPressed:E}=T({onPressStart:h,onPressEnd:g,onPressChange:_,onPressUp:y,onClick:b,onPress(e){v?.(e),n.toggle(),r.current?.focus()},isDisabled:i||a}),{focusableProps:D}=oe(t,r),ee=A(S,D),O=e(t,{labelable:!0});return Fe(r,n.defaultSelected,n.setSelected),{labelProps:A(w,{onClick:e=>e.preventDefault()}),inputProps:A(O,{"aria-invalid":m||f===`invalid`||void 0,"aria-errormessage":t[`aria-errormessage`],"aria-controls":t[`aria-controls`],"aria-readonly":a||void 0,onChange:x,disabled:i,...o==null?{}:{value:o},name:s,form:c,type:`checkbox`,...ee}),isSelected:n.isSelected,isPressed:C||E,isDisabled:i,isReadOnly:a,isInvalid:m||f===`invalid`}}function et(e,t,n){let r=J({...e,value:t.isSelected}),{isInvalid:i,validationErrors:a,validationDetails:o}=r.displayValidation,{labelProps:s,inputProps:c,isSelected:l,isPressed:u,isDisabled:d,isReadOnly:f}=$e({...e,isInvalid:i},t,n);Re(e,r,n);let{isIndeterminate:p,isRequired:m,validationBehavior:h=`aria`}=e;R(()=>{n.current&&(n.current.indeterminate=!!p)});let{pressProps:g}=T({isDisabled:d||f,onPress(){let{[Ge]:t}=e,{commitValidation:n}=t||r;n()}});return{labelProps:A(s,g,z(()=>({onMouseDown:e=>e.preventDefault()}),[])),inputProps:{...c,checked:l,"aria-required":m&&h===`aria`||void 0,required:m&&h===`native`},isSelected:l,isPressed:u,isDisabled:d,isReadOnly:f,isInvalid:i,validationErrors:a,validationDetails:o}}const tt=new WeakMap;function nt(t,n){let{isDisabled:r,name:i,form:a,validationBehavior:o=`aria`}=t,{isInvalid:s,validationErrors:c,validationDetails:l}=n.displayValidation,{labelProps:u,fieldProps:d,descriptionProps:f,errorMessageProps:p}=Le({...t,labelElementType:`span`,isInvalid:s,errorMessage:t.errorMessage||c});tt.set(n,{name:i,form:a,descriptionId:f.id,errorMessageId:p.id,validationBehavior:o});let m=e(t,{labelable:!0}),{focusWithinProps:h}=k({onBlurWithin:t.onBlur,onFocusWithin:t.onFocus,onFocusWithinChange:t.onFocusChange});return{groupProps:A(m,{role:`group`,"aria-disabled":r||void 0,...d,...h}),labelProps:u,descriptionProps:f,errorMessageProps:p,isInvalid:s,validationErrors:c,validationDetails:l}}function rt(e={}){let{isReadOnly:t}=e,[n,r]=ce(e.isSelected,e.defaultSelected||!1,e.onChange),[i]=V(n);function a(e){t||r(e)}function o(){t||r(!n)}return{isSelected:n,defaultSelected:e.defaultSelected??i,setSelected:a,toggle:o}}function it(e,t,n){let r=rt({isReadOnly:e.isReadOnly||t.isReadOnly,isSelected:t.isSelected(e.value),defaultSelected:t.defaultValue.includes(e.value),onChange(n){n?t.addValue(e.value):t.removeValue(e.value),e.onChange&&e.onChange(n)}}),{name:i,form:a,descriptionId:o,errorMessageId:s,validationBehavior:c}=tt.get(t);c=e.validationBehavior??c;let{realtimeValidation:l}=J({...e,value:r.isSelected,name:void 0,validationBehavior:`aria`}),u=B(q),d=()=>{t.setInvalid(e.value,l.isInvalid?l:u.current)};R(d);let f=t.realtimeValidation.isInvalid?t.realtimeValidation:l,p=c===`native`?t.displayValidation:f,m=et({...e,isReadOnly:e.isReadOnly||t.isReadOnly,isDisabled:e.isDisabled||t.isDisabled,name:e.name||i,form:e.form||a,isRequired:e.isRequired??t.isRequired,validationBehavior:c,[Ge]:{realtimeValidation:f,displayValidation:p,resetValidation:t.resetValidation,commitValidation:t.commitValidation,updateValidation(e){u.current=e,d()}}},r,n);return{...m,inputProps:{...m.inputProps,"aria-describedby":[e[`aria-describedby`],t.isInvalid?s:null,o].filter(Boolean).join(` `)||void 0}}}const at=new WeakMap;function ot(t,n,r){let{value:i,children:a,"aria-label":o,"aria-labelledby":s,onPressStart:c,onPressEnd:l,onPressChange:u,onPress:d,onPressUp:f,onClick:p}=t,m=t.isDisabled||n.isDisabled,h=n.selectedValue===i,g=e=>{e.stopPropagation(),n.setSelectedValue(i)},{pressProps:_,isPressed:v}=T({onPressStart:c,onPressEnd:l,onPressChange:u,onPress:d,onPressUp:f,onClick:p,isDisabled:m}),{pressProps:y,isPressed:b}=T({onPressStart:c,onPressEnd:l,onPressChange:u,onPressUp:f,onClick:p,isDisabled:m,onPress(e){d?.(e),n.setSelectedValue(i),r.current?.focus()}}),{focusableProps:x}=oe(A(t,{onFocus:()=>n.setLastFocusedValue(i)}),r),S=A(_,x),C=e(t,{labelable:!0}),w=-1;n.selectedValue==null?(n.lastFocusedValue===i||n.lastFocusedValue==null)&&(w=0):n.selectedValue===i&&(w=0),m&&(w=void 0);let{name:E,form:D,descriptionId:ee,errorMessageId:O,validationBehavior:k}=at.get(n);return Fe(r,n.defaultSelectedValue,n.setSelectedValue),Re({validationBehavior:k},n,r),{labelProps:A(y,z(()=>({onClick:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault()}),[])),inputProps:A(C,{...S,type:`radio`,name:E,form:D,tabIndex:w,disabled:m,required:n.isRequired&&k===`native`,checked:h,value:i,onChange:g,"aria-describedby":[t[`aria-describedby`],n.isInvalid?O:null,ee].filter(Boolean).join(` `)||void 0}),isDisabled:m,isSelected:h,isPressed:v||b}}function st(t,n){let{name:r,form:i,isReadOnly:a,isRequired:o,isDisabled:s,orientation:l=`vertical`,validationBehavior:u=`aria`}=t,{direction:d}=pe(),{isInvalid:f,validationErrors:m,validationDetails:g}=n.displayValidation,{labelProps:_,fieldProps:v,descriptionProps:y,errorMessageProps:b}=Le({...t,labelElementType:`span`,isInvalid:n.isInvalid,errorMessage:t.errorMessage||m}),x=e(t,{labelable:!0}),{focusWithinProps:S}=k({onBlurWithin(e){t.onBlur?.(e),n.selectedValue||n.setLastFocusedValue(null)},onFocusWithin:t.onFocus,onFocusWithinChange:t.onFocusChange}),C=e=>{let t;switch(e.key){case`ArrowRight`:t=d===`rtl`&&l!==`vertical`?`prev`:`next`;break;case`ArrowLeft`:t=d===`rtl`&&l!==`vertical`?`next`:`prev`;break;case`ArrowDown`:t=`next`;break;case`ArrowUp`:t=`prev`;break;default:return}e.preventDefault();let r=ne(e.currentTarget,{from:p(e),accept:e=>e instanceof h(e).HTMLInputElement&&e.type===`radio`}),i;t===`next`?(i=r.nextNode(),i||=(r.currentNode=e.currentTarget,r.firstChild())):(i=r.previousNode(),i||=(r.currentNode=e.currentTarget,r.lastChild())),i&&(i.focus(),n.setSelectedValue(i.value))},w=c(r);return at.set(n,{name:w,form:i,descriptionId:y.id,errorMessageId:b.id,validationBehavior:u}),{radioGroupProps:A(x,{role:`radiogroup`,onKeyDown:C,"aria-invalid":n.isInvalid||void 0,"aria-errormessage":t[`aria-errormessage`],"aria-readonly":a||void 0,"aria-required":o||void 0,"aria-disabled":s||void 0,"aria-orientation":l,...v,...S}),labelProps:_,descriptionProps:y,errorMessageProps:b,isInvalid:f,validationErrors:m,validationDetails:g}}const ct=F({}),Y=I(function(e,t){[e,t]=D(e,t,ct);let{elementType:n=`span`,...r}=e,i=M[n];return P.createElement(i,{className:`react-aria-Text`,...r,ref:t})});function lt(e={}){let[t,n]=ce(e.value,e.defaultValue||[],e.onChange),[r]=V(t),i=!!e.isRequired&&t.length===0,a=B(new Map),o=J({...e,value:t}),s=o.displayValidation.isInvalid;return{...o,value:t,defaultValue:e.defaultValue??r,setValue(t){e.isReadOnly||e.isDisabled||n(t)},isDisabled:e.isDisabled||!1,isReadOnly:e.isReadOnly||!1,isSelected(e){return t.includes(e)},addValue(t){e.isReadOnly||e.isDisabled||n(e=>e.includes(t)?e:e.concat(t))},removeValue(r){e.isReadOnly||e.isDisabled||t.includes(r)&&n(t.filter(e=>e!==r))},toggleValue(r){e.isReadOnly||e.isDisabled||(t.includes(r)?n(t.filter(e=>e!==r)):n(t.concat(r)))},setInvalid(e,t){let n=new Map(a.current);t.isInvalid?n.set(e,t):n.delete(e),a.current=n,o.updateValidation(Ze(...n.values()))},validationState:e.validationState??(s?`invalid`:null),isInvalid:s,isRequired:i}}let ut=Math.round(Math.random()*1e10),dt=0;function ft(e){let t=z(()=>e.name||`radio-group-${ut}-${++dt}`,[e.name]),[n,r]=ce(e.value,e.defaultValue??null,e.onChange),[i]=V(n),[a,o]=V(null),s=J({...e,value:n}),c=t=>{!e.isReadOnly&&!e.isDisabled&&(r(t),s.commitValidation())},l=s.displayValidation.isInvalid;return{...s,name:t,selectedValue:n,defaultSelectedValue:e.value===void 0?e.defaultValue??null:i,setSelectedValue:c,lastFocusedValue:a,setLastFocusedValue:o,isDisabled:e.isDisabled||!1,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1,validationState:e.validationState||(l?`invalid`:null),isInvalid:l}}const X=F(null),Z=I(function(e,t){return Se(X)?.isInvalid?P.createElement(pt,{...e,ref:t}):null}),pt=I((t,n)=>{let r=Se(X),i=e(t,{global:!0}),a=N({...t,defaultClassName:`react-aria-FieldError`,defaultChildren:r.validationErrors.length===0?void 0:r.validationErrors.join(` `),values:r});return a.children==null?null:P.createElement(Y,{slot:`errorMessage`,...i,...a,ref:n})}),mt=F(null),ht=F(null),gt=F(null),_t=I(function(t,n){[t,n]=D(t,n,ht);let{validationBehavior:r}=i(mt)||{},a=t.validationBehavior??r??`native`,o=lt({...t,validationBehavior:a}),[s,c]=_(!t[`aria-label`]&&!t[`aria-labelledby`]),{groupProps:l,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=nt({...t,label:c,validationBehavior:a},o),m=N({...t,values:{isDisabled:o.isDisabled,isReadOnly:o.isReadOnly,isRequired:t.isRequired||!1,isInvalid:o.isInvalid,state:o},defaultClassName:`react-aria-CheckboxGroup`}),h=e(t,{global:!0});return P.createElement(M.div,{...A(h,m,l),ref:n,slot:t.slot||void 0,"data-readonly":o.isReadOnly||void 0,"data-required":t.isRequired||void 0,"data-invalid":o.isInvalid||void 0,"data-disabled":t.isDisabled||void 0},P.createElement(me,{values:[[gt,o],[se,{...u,ref:s,elementType:`span`}],[ct,{slots:{description:d,errorMessage:f}}],[X,p]]},m.children))}),vt=I(function(t,n){let{inputRef:r=null,...a}=t;[t,n]=D(a,n,he);let{validationBehavior:o}=i(mt)||{},s=t.validationBehavior??o??`native`,c=Se(gt),l=m(z(()=>f(r,t.inputRef===void 0?null:t.inputRef),[r,t.inputRef])),{labelProps:u,inputProps:d,isSelected:p,isDisabled:h,isReadOnly:g,isPressed:_,isInvalid:y}=c?it({...v(t),value:t.value,children:typeof t.children==`function`?!0:t.children},c,l):et({...v(t),children:typeof t.children==`function`?!0:t.children,validationBehavior:s},rt(t),l),{isFocused:b,isFocusVisible:x,focusProps:S}=O(),C=h||g,{hoverProps:w,isHovered:T}=fe({...t,isDisabled:C}),E=N({...t,defaultClassName:`react-aria-Checkbox`,values:{isSelected:p,isIndeterminate:t.isIndeterminate||!1,isPressed:_,isHovered:T,isFocused:b,isFocusVisible:x,isDisabled:h,isReadOnly:g,isInvalid:y,isRequired:t.isRequired||!1}}),k=e(t,{global:!0});return delete k.id,delete k.onClick,P.createElement(M.label,{...A(k,u,w,E),ref:n,slot:t.slot||void 0,"data-selected":p||void 0,"data-indeterminate":t.isIndeterminate||void 0,"data-pressed":_||void 0,"data-hovered":T||void 0,"data-focused":b||void 0,"data-focus-visible":x||void 0,"data-disabled":h||void 0,"data-readonly":g||void 0,"data-invalid":y||void 0,"data-required":t.isRequired||void 0},P.createElement(ee,{elementType:`span`},P.createElement(`input`,{...A(d,S),ref:l})),E.children)}),yt=F({}),bt=F({});let xt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const St=ae(function(e,t){[e,t]=D(e,t,bt);let{hoverProps:n,isHovered:r}=fe({...e,isDisabled:e.disabled}),{isFocused:i,isFocusVisible:a,focusProps:o}=O({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=N({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-Input`});return P.createElement(M.input,{...A(xt(e),o,n),...c,ref:t,"data-focused":i||void 0,"data-disabled":e.disabled||void 0,"data-hovered":r||void 0,"data-focus-visible":a||void 0,"data-invalid":s||void 0})}),Ct=F(null);function wt(e){let t=B({});return P.createElement(Ct.Provider,{value:t},e.children)}const Tt=F({isSelected:!1}),Et=F(null),Dt=F(null),Ot=F(null),kt=I(function(t,n){[t,n]=D(t,n,Et);let{validationBehavior:r}=i(mt)||{},a=t.validationBehavior??r??`native`,o=ft({...t,validationBehavior:a}),[s,c]=_(!t[`aria-label`]&&!t[`aria-labelledby`]),{radioGroupProps:l,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=st({...t,label:c,validationBehavior:a},o),m=N({...t,values:{orientation:t.orientation||`vertical`,isDisabled:o.isDisabled,isReadOnly:o.isReadOnly,isRequired:o.isRequired,isInvalid:o.isInvalid,state:o},defaultClassName:`react-aria-RadioGroup`}),h=e(t,{global:!0});return P.createElement(M.div,{...A(h,m,l),ref:n,slot:t.slot||void 0,"data-orientation":t.orientation||`vertical`,"data-invalid":o.isInvalid||void 0,"data-disabled":o.isDisabled||void 0,"data-readonly":o.isReadOnly||void 0,"data-required":o.isRequired||void 0},P.createElement(me,{values:[[Ot,o],[se,{...u,ref:s,elementType:`span`}],[ct,{slots:{description:d,errorMessage:f}}],[X,p]]},P.createElement(wt,null,m.children)))}),At=I(function(t,n){let{inputRef:r=null,...i}=t;[t,n]=D(i,n,Dt);let a=P.useContext(Ot),o=m(z(()=>f(r,t.inputRef===void 0?null:t.inputRef),[r,t.inputRef])),{labelProps:s,inputProps:c,isSelected:l,isDisabled:u,isPressed:d}=ot({...v(t),children:typeof t.children==`function`?!0:t.children},a,o),{isFocused:p,isFocusVisible:h,focusProps:g}=O(),_=u||a.isReadOnly,{hoverProps:y,isHovered:b}=fe({...t,isDisabled:_}),x=N({...t,defaultClassName:`react-aria-Radio`,values:{isSelected:l,isPressed:d,isHovered:b,isFocused:p,isFocusVisible:h,isDisabled:u,isReadOnly:a.isReadOnly,isInvalid:a.isInvalid,isRequired:a.isRequired}}),S=e(t,{global:!0});return delete S.id,delete S.onClick,P.createElement(M.label,{...A(S,s,y,x),ref:n,"data-selected":l||void 0,"data-pressed":d||void 0,"data-hovered":b||void 0,"data-focused":p||void 0,"data-focus-visible":h||void 0,"data-disabled":u||void 0,"data-readonly":a.isReadOnly||void 0,"data-invalid":a.isInvalid||void 0,"data-required":a.isRequired||void 0},P.createElement(ee,{elementType:`span`},P.createElement(`input`,{...A(c,g),ref:o})),P.createElement(Tt.Provider,{value:{isSelected:l}},x.children))}),jt=F({});let Mt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const Nt=I(function(e,t){[e,t]=D(e,t,jt);let{hoverProps:n,isHovered:r}=fe(e),{isFocused:i,isFocusVisible:a,focusProps:o}=O({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=N({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-TextArea`});return P.createElement(M.textarea,{...A(Mt(e),o,n),...c,ref:t,"data-focused":i||void 0,"data-disabled":e.disabled||void 0,"data-hovered":r||void 0,"data-focus-visible":a||void 0,"data-invalid":s||void 0})}),Pt=F(null),Ft=ae(function(t,n){[t,n]=D(t,n,Pt);let{validationBehavior:r}=i(mt)||{},a=t.validationBehavior??r??`native`,o=B(null);[t,o]=D(t,o,g);let[s,c]=_(!t[`aria-label`]&&!t[`aria-labelledby`]),[l,u]=V(`input`),{labelProps:d,inputProps:f,descriptionProps:p,errorMessageProps:m,...h}=Qe({...v(t),inputElementType:l,label:c,validationBehavior:a},o),y=L(e=>{o.current=e,e&&u(e instanceof HTMLTextAreaElement?`textarea`:`input`)},[o]),b=N({...t,values:{isDisabled:t.isDisabled||!1,isInvalid:h.isInvalid,isReadOnly:t.isReadOnly||!1,isRequired:t.isRequired||!1},defaultClassName:`react-aria-TextField`}),x=e(t,{global:!0});return delete x.id,P.createElement(M.div,{...x,...b,ref:n,slot:t.slot||void 0,"data-disabled":t.isDisabled||void 0,"data-invalid":h.isInvalid||void 0,"data-readonly":t.isReadOnly||void 0,"data-required":t.isRequired||void 0},P.createElement(me,{values:[[se,{...d,ref:s}],[bt,{...f,ref:y}],[jt,{...f,ref:y}],[yt,{role:`presentation`,isInvalid:h.isInvalid,isDisabled:t.isDisabled||!1}],[ct,{slots:{description:p,errorMessage:m}}],[X,h]]},b.children))}),Q=({title:e,description:t,classNames:n})=>{let{survey:r,dismiss:i}=s();if(!r)return null;let a=t||r.confirmation.description;return W(H,{children:[U(`div`,{className:G(`cf-question`,n?.question),children:W(`div`,{className:G(`cf-header`,n?.header),children:[U(j,{className:G(`cf-title`,n?.title),children:e||r.confirmation.title||`Feedback submitted!`}),a&&U(Y,{slot:`description`,className:G(`cf-description`,n?.description),children:a})]})}),U(E,{className:`cf-submit-button`,onPress:i,children:r.confirmation.buttonText||`Close`})]})},It=({children:e,classNames:t,containerProps:n,onDismiss:r,closeOnFinishMs:i=3e3})=>{let{surveyId:a,survey:o,dismiss:c}=s(),[l,u]=V(!1),[d,f]=V(!1),[p,m]=V(!1);return Te(()=>{o&&c()},l&&!(d||p)?i:null),W(`div`,{className:G(`confetti-dialog`,t?.dialog),id:`${a}-popover`,...n,onMouseEnter:e=>{n?.onMouseEnter?.(e),f(!0)},onMouseLeave:e=>{n?.onMouseLeave?.(e),f(!1)},onFocusCapture:e=>{n?.onFocusCapture?.(e),m(!0)},onBlurCapture:e=>{n?.onBlurCapture?.(e),e.currentTarget.contains(e.relatedTarget)||m(!1)},children:[U(ue,{className:G(`confetti-dialog-close`,t?.closeButton),iconClassName:t?.icon,onClose:async()=>{await c(),r?.()}}),typeof e==`function`?e({setIsFinished:()=>u(!0)}):e]})},Lt=3e4;Lt/1e3;const Rt=({redactClasses:e=[]}={})=>{let[t,n]=V(null),[r,i]=V(!1),[a,o]=V(null),[s,c]=V(30),l=B(null),u=B(null),d=B(null),f=B([]);R(()=>{let e=new CustomEvent(ve,{detail:{isRecording:r}});document.dispatchEvent(e)},[r]);let p=L(()=>{u.current&&=(clearInterval(u.current),null),d.current&&=(clearTimeout(d.current),null),l.current=null,c(Lt/1e3)},[]),m=L(()=>{l.current?.(),p(),i(!1),n(JSON.stringify(f.current))},[p]);return{recordingEventsJson:t,isRecording:r,recordingError:a,remainingSeconds:s,startRecording:L(async()=>{i(!0),o(null),n(null),f.current=[];try{let{record:t}=await import(`./record-CeeyzJpB.js`),n=e[0];l.current=t({slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0},sampling:{mousemove:50,scroll:100,input:`last`},emit:e=>{f.current.push(e)},...n?{blockClass:n}:{}})??null;let r=Lt/1e3;c(r),u.current=setInterval(()=>{--r,c(r)},1e3),d.current=setTimeout(()=>{m()},Lt)}catch{o(`Failed to start recording. Please try again.`),i(!1),p()}},[e,m,p]),stopRecording:m,clear:L(()=>{p(),i(!1),n(null),o(null),f.current=[]},[p])}},zt=({redactClasses:e=[]}={})=>{let[t,n]=V(null),[r,i]=V(!1),[a,o]=V(null);return{screenshotDataUrl:t,isCapturing:r,captureError:a,capture:L(async()=>{i(!0),o(null);try{let t=(await import(`./html2canvas-pro.esm-C4mKZXvx.js`)).default;n((await t(document.body,{logging:!1,ignoreElements:t=>e.some(e=>t.classList.contains(e))})).toDataURL(`image/png`))}catch{o(`Failed to capture screenshot. Please try again.`)}finally{i(!1)}},[e]),clear:L(()=>{n(null),o(null)},[])}},Bt=e=>W(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[U(`circle`,{cx:`12`,cy:`12`,r:`10`}),U(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`})]}),Vt=e=>W(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[U(`path`,{d:`M10 11v6`}),U(`path`,{d:`M14 11v6`}),U(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),U(`path`,{d:`M3 6h18`}),U(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]});function Ht(){if(window.DD_RUM&&typeof window.DD_RUM?.getInternalContext==`function`&&typeof window.DD_RUM?.getSessionReplayLink==`function`)try{let e=window.DD_RUM?.getInternalContext?.(),t=window.DD_RUM?.getSessionReplayLink?.();return{sessionId:e?.session_id,sessionReplayLink:t}}catch{return null}return null}function Ut(){if(typeof window>`u`||typeof navigator>`u`)return;let e=navigator,t=window.screen,n=Ht();return{userAgent:e.userAgent,screenResolution:`${t.width}x${t.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,pageUrl:window.location.href,pageTitle:document.title,referrer:document.referrer,language:e.language,timestamp:new Date().toISOString(),datadogTraceId:n?.traceId,datadogSessionId:n?.sessionId,datadogSessionReplayLink:n?.sessionReplayLink}}const Wt=xe(()=>import(`./RecordingReplayer-CKYzAfYD.js`)),Gt=({id:e,title:t,description:n,properties:r,onChange:i,required:a,error:o,classNames:s})=>{let c=z(()=>Ut(),[]),[l,u]=V(``),[d,f]=V(``),{screenshotDataUrl:p,isCapturing:m,captureError:h,capture:g,clear:_}=zt({redactClasses:r.redactClasses}),{recordingEventsJson:v,isRecording:y,recordingError:b,remainingSeconds:x,startRecording:S,stopRecording:C,clear:w}=Rt({redactClasses:r.redactClasses}),T=z(()=>({title:l,...d?{description:d}:{},...p?{screenshotDataUrl:p}:{},...v?{recordingEventsJson:v}:{},metadata:c}),[d,c,v,p,l]);R(()=>{i(T)},[T,i]),R(()=>()=>{C()},[C]);let D=z(()=>v?JSON.parse(v):[],[v]);return U(H,{children:y?W(E,{className:G(`cf-bug-report-button`,`cf-bug-report-record-button`,s?.button,s?.recordButton),onPress:C,children:[U(Bt,{}),W(`span`,{children:[30-x,`s /`,` `,30,`s`]})]}):W(`div`,{className:G(`cf-bug-report`,s?.base),children:[W(Ft,{isRequired:a,isInvalid:!!o,name:`${e}-title`,value:l,onChange:u,className:G(`cf-question`,s?.question),children:[W(`div`,{className:G(`cf-header`,s?.header),children:[W(j,{className:G(`cf-title`,s?.title),children:[t,!a&&W(`span`,{className:G(`cf-label-optional`,s?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,s?.description),children:n})]}),U(St,{placeholder:r.placeholder||`Brief description of the issue`,className:G(`cf-input`,s?.input)})]}),W(Ft,{name:`${e}-description`,value:d,onChange:f,className:G(`cf-question`,s?.question),children:[U(j,{className:G(`cf-title`,s?.title),children:r.detailsLabel}),U(Nt,{placeholder:r.detailsPlaceholder||`Steps to reproduce, expected vs actual behavior, etc.`,className:G(`cf-textarea`,s?.textArea),rows:4})]}),r.enableScreenshot||r.enableRecording?W(`section`,{className:G(`cf-question`,s?.question),children:[U(j,{className:G(`cf-title`,s?.title),children:`Attachments`}),W(`div`,{className:G(`cf-bug-report-actions`,s?.actions),children:[r.enableScreenshot&&W(`div`,{className:G(`cf-bug-report-screenshot-section`,s?.screenshotSection),children:[p?W(`div`,{className:G(`cf-bug-report-media-preview`,s?.mediaPreview),children:[U(`img`,{src:p,alt:`Screenshot preview`,className:G(`cf-bug-report-screenshot-img`,s?.screenshotImg)}),U(`div`,{className:G(`cf-bug-report-media-actions`,s?.mediaActions),children:U(E,{className:G(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:_,"aria-label":`Remove screenshot`,children:U(Vt,{})})})]}):U(E,{className:G(`cf-bug-report-button`,s?.button),onPress:g,isDisabled:m,children:m?`Capturing...`:`Screenshot`}),h&&U(`div`,{className:G(`cf-error`,s?.error),children:h})]}),r.enableRecording&&W(`div`,{className:G(`cf-bug-report-recording-section`,s?.recordingSection),children:[D.length>0?W(`div`,{className:G(`cf-bug-report-media-preview`,s?.mediaPreview),children:[U(be,{fallback:U(`span`,{className:G(`cf-bug-report-player-loading`,s?.playerLoading),"aria-label":`Loading recording preview...`}),children:U(Wt,{events:D})}),U(`div`,{className:G(`cf-bug-report-media-actions`,s?.mediaActions),children:U(E,{className:G(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:w,"aria-label":`Remove recording`,children:U(Vt,{})})})]}):U(E,{className:G(`cf-bug-report-button`,s?.button),onPress:S,children:`Record`}),b&&U(`div`,{className:G(`cf-error`,s?.error),children:b})]})]})]}):null,U(Z,{className:G(`cf-error`,s?.error),children:o})]})})},Kt=({id:e,title:t,description:n,properties:r,onChange:i,classNames:a,required:o,error:s})=>{let[c,l]=V(``);return R(()=>{i(c)},[i,c]),W(Ft,{isRequired:o,isInvalid:!!s,name:e,className:G(`cf-question`,a?.question),value:c,onChange:e=>{l(e),i(e)},children:[W(`div`,{className:G(`cf-header`,a?.header),children:[W(j,{className:G(`cf-title`,a?.title),children:[t,!o&&W(`span`,{className:G(`cf-label-optional`,a?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,a?.description),children:n})]}),U(Nt,{className:G(`cf-textarea`,a?.textarea),maxLength:r.max,rows:4,placeholder:r.placeholder||`Start typing...`}),U(Z,{className:G(`cf-error`,a?.error),children:s})]})},qt=({children:e,classNames:t,description:n,...r})=>U(vt,{...r,children:({isIndeterminate:r})=>W(H,{children:[W(`div`,{className:G(`cf-choice-label`,t?.label),children:[U(`div`,{className:G(`cf-checkbox-indicator`,t?.indicator),children:U(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:G(`cf-checkbox-indicator-svg`,t?.svg),children:r?U(`rect`,{x:1,y:7.5,width:16,height:3}):U(`polyline`,{points:`2 9 7 14 16 4`})},r?`indeterminate`:`check`)}),e]}),n&&U(`span`,{className:G(`cf-choice-description`,t?.choiceDescription),children:n})]})}),Jt=({children:e,classNames:t,...n})=>U(vt,{...n,children:U(`div`,{className:G(`cf-tag-label`,t?.tagLabel),children:e})}),Yt=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s})=>{let c=!!n.editable,l=n.display??`checkbox`,[u,d]=V([]),[f,p]=V(``),m=B(null),h=B(null),g=z(()=>{let e=u.indexOf(C);if(e===-1)return u;let t=[...u];return t[e]=f||C,t},[f,u]),_=l===`tag`;return R(()=>{i(g)},[i,g]),U(_t,{isRequired:o,isInvalid:!!s,name:a,value:u,onChange:d,className:G(`cf-question`,r?.question),children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(j,{className:G(`cf-title`,r?.title),children:[e,!o&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:t})]}),W(`div`,{className:G(`cf-response-choices`,l===`tag`&&`cf-response-choices-tag`,r?.group),children:[n.options.map((e,t)=>U(_?Jt:qt,{className:G(`cf-choice`,_&&[`cf-tag`,r?.tag],!_&&[`cf-checkbox`,r?.checkbox]),description:e.description,value:e.value,classNames:{tag:r?.tag,tagLabel:r?.tagLabel,choiceDescription:r?.choiceDescription,label:r?.label,indicator:r?.indicator,svg:r?.svg},children:e.value},t)),c&&(_?W(H,{children:[U(Jt,{inputRef:m,onChange:e=>{h.current&&e&&requestAnimationFrame(()=>{h.current&&h.current.focus()})},className:G(`cf-choice cf-tag`,r?.tag),value:C,children:n.editable?.label}),U(St,{"data-visible":i.value.includes(C)||void 0,value:f,onChange:e=>{p(e.target.value)},ref:h,className:G(`cf-input cf-tag-input`,r?.othersInput)})]}):W(`div`,{className:G(`cf-choice cf-others-choice`,r?.othersChoice),children:[U(qt,{inputRef:m,onChange:e=>{h.current&&e&&requestAnimationFrame(()=>{h.current&&h.current.focus()})},className:G(`cf-checkbox`,r?.checkbox),value:C,classNames:{indicator:r?.indicator,svg:r?.svg},description:n.editable?.description,children:n.editable?.label}),U(St,{value:f,onChange:e=>{p(e.target.value)},tabIndex:i.value.includes(C)?0:-1,ref:h,onFocus:()=>{m.current?.checked===!1&&m.current.click()},className:G(`cf-input`,r?.othersInput)})]}))]}),U(Z,{className:G(`cf-error`,r?.error),children:s})]})})},Xt=e=>W(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M7.5 8 10 9M14 9l2.5-1M9 10h.01M15 10h.01`})]}),Zt=e=>W(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12ZM9 9h.01M15 9h.01`})]}),Qt=e=>W(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M9 9h.01M15 9h.01`})]}),$t=e=>W(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M8 15h8M9 9h.01M15 9h.01`})]}),en=e=>W(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[U(`circle`,{cx:12,cy:12,r:10}),U(`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01`})]}),tn=e=>U(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:40,height:40,fill:`none`,...e,children:U(`path`,{fill:`currentColor`,d:`m6.516 14.323-1.49 6.452a.998.998 0 0 0 1.529 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4 4.536-4.082a1 1 0 0 0-.59-1.74l-5.701-.454-2.467-5.461a.998.998 0 0 0-1.822 0L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.214 4.107zm2.853-4.326a.998.998 0 0 0 .832-.586L12 5.43l1.799 3.981a.998.998 0 0 0 .832.586l3.972.315-3.271 2.944c-.284.256-.397.65-.293 1.018l1.253 4.385-3.736-2.491a.995.995 0 0 0-1.109 0l-3.904 2.603 1.05-4.546a1 1 0 0 0-.276-.94l-3.038-2.962 4.09-.326z`})}),nn=e=>U(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,...e,children:U(`path`,{fill:`currentColor`,d:`M21.947 9.179a1.001 1.001 0 0 0-.868-.676l-5.701-.453-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4 4.536-4.082c.297-.268.406-.686.278-1.065z`})}),rn=({state:e,properties:t,classNames:n})=>{let r=e.selectedValue?Number(e.selectedValue):null;return U(`div`,{className:G(`cf-rating-display-star`,n?.ratingDisplayStar),children:Array.from({length:t.scale},(e,t)=>{let i=t+1,a=String(i),o=r&&i<=r;return U(At,{className:G(`cf-rating-star`,n?.ratingStar),value:a,"data-filled":o?`true`:void 0,children:U(o?nn:tn,{})},t)})})},an=({properties:e,classNames:t})=>U(`div`,{className:G(`cf-rating-display-number`,t?.ratingDisplayNumber),children:Array.from({length:e.scale},(e,n)=>{let r=n+1,i=String(r);return U(At,{className:G(`cf-rating-number`,t?.ratingNumber),value:i,children:r},n)})}),on=({properties:e,classNames:t,state:n})=>{let r=z(()=>[Xt,Qt,$t,en,Zt],[]),i=z(()=>[Qt,$t,en],[]);return z(()=>e.scale===3||e.scale===5,[e.scale])?U(`div`,{className:G(`cf-rating-display-emoji`,t?.ratingDisplayEmoji),children:Array.from({length:e.scale},(n,a)=>{let o=a+1,s=String(o),c=e.scale===5?r[a]:i[a];return U(At,{className:G(`cf-rating-emoji`,t?.ratingEmoji),value:s,children:c&&U(c,{})},a)})}):U(an,{properties:e,classNames:t,state:n})},sn=e=>{switch(e.properties.display??`star`){case`emoji`:return U(on,{...e});case`number`:return U(an,{...e});case`star`:return U(rn,{...e})}},cn=({properties:e,title:t,description:n,classNames:r,onChange:i,id:a,error:o,required:s})=>{let[c,l]=V(null),u=z(()=>c?Number(c):void 0,[c]);return R(()=>{i(u)},[i,u]),U(kt,{isRequired:s,isInvalid:!!o,name:a,className:G(`cf-question`,r?.question),value:c,onChange:l,children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(j,{className:G(`cf-title`,r?.title),children:[t,!s&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),n&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:n})]}),W(`div`,{className:G(`cf-rating-section`,r?.ratingSection),children:[U(sn,{state:i,properties:e,classNames:r}),W(`div`,{className:G(`cf-rating-text`,r?.ratingText),children:[U(`span`,{className:G(`cf-rating-text-lower`,r?.ratingTextLower),children:e.labels?.lower}),U(`span`,{className:G(`cf-rating-text-upper`,r?.ratingTextUpper),children:e.labels?.upper})]})]}),U(Z,{className:G(`cf-error`,r?.error),children:o})]})})},ln=({classNames:e,className:t,description:r,...i})=>U(At,{...i,className:G(t,e?.radio),children:n(i.children,t=>W(H,{children:[W(`div`,{className:G(`cf-choice-label`,e?.label),children:[U(`div`,{className:G(`cf-radio-indicator`,e?.indicator)}),t]}),r&&U(`span`,{className:G(`cf-choice-description`,e?.choiceDescription),children:r})]}))}),un=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s})=>{let[c,l]=V(null),[u,d]=V(``),f=!!n.editable,p=B(null),m=B(null),h=z(()=>c===S?u||S:c??void 0,[u,c]);return R(()=>{i(h)},[i,h]),U(kt,{isRequired:o,isInvalid:!!s,name:a,onChange:e=>{l(e),e===S&&requestAnimationFrame(()=>{m.current&&m.current.focus()})},value:c,className:G(`cf-question`,r?.question),children:({state:i})=>W(H,{children:[W(`div`,{className:G(`cf-header`,r?.header),children:[W(j,{className:G(`cf-title`,r?.title),children:[e,!o&&W(`span`,{className:G(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&U(Y,{slot:`description`,className:G(`cf-description`,r?.description),children:t})]}),W(`div`,{className:G(`cf-response-choices`,r?.group),children:[n.options.map((e,t)=>U(ln,{classNames:{indicator:r?.indicator,radio:G(`cf-choice cf-radio`,r?.radio)},value:e.value,description:e.description,children:e.value},t)),f&&W(`div`,{className:G(`cf-choice cf-others-choice`,r?.othersChoice),children:[U(ln,{inputRef:p,value:S,classNames:{indicator:r?.indicator,radio:G(`cf-radio`,r?.radio)},description:n.editable?.description,children:n.editable?.label}),U(St,{tabIndex:i.selectedValue===S?0:-1,ref:m,value:u,onChange:e=>d(e.target.value),onFocus:()=>{p.current?.checked===!1&&p.current.click()},className:G(`cf-input`,r?.othersInput)})]})]}),U(Z,{className:G(`cf-error`,r?.error),children:s})]})})},dn=({properties:e,title:t,description:n,classNames:r})=>U(`div`,{className:G(`cf-question`,r?.question),children:W(`div`,{className:G(`cf-header`,r?.header),children:[t&&U(`div`,{className:G(`cf-title`,r?.title),children:t}),n&&U(`div`,{className:G(`cf-description`,r?.description),children:n})]})}),$=({question:e,onChange:t,error:n})=>{switch(e.properties.type){case`rating`:return U(cn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`open-ended`:return U(Kt,{...e,properties:e.properties,onChange:t,error:n},e.id);case`single-select`:return U(un,{...e,properties:e.properties,onChange:t,error:n},e.id);case`multi-select`:return U(Yt,{...e,properties:e.properties,onChange:t,error:n},e.id);case`statement`:return U(dn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`bug-report`:return U(Gt,{...e,properties:e.properties,onChange:t,error:n},e.id)}return U(`div`,{children:`Unsupported question type`},e.id)},fn=({onPress:e,isDisabled:t,children:n=`Submit`})=>re()?null:U(E,{isDisabled:t,className:`cf-submit-button`,onPress:e,children:n}),pn=e=>{switch(e){case`multi-select`:return[];case`bug-report`:return{title:``};case`statement`:return;default:return``}},mn=e=>e!==void 0&&e!==``&&!(Array.isArray(e)&&e.length===0),hn=({onSubmit:e,children:t,question:n,isLastQuestion:r})=>{let[i,a]=V(pn(n.properties.type)),o=z(()=>Oe(n.properties,{required:n.required}),[n.properties,n.required]),s=z(()=>{let e=o.safeParse(i);if(!e.success)return De(e.error)},[i,o]),c=z(()=>{let e=n.routingLogic;if(e.type!==`always`&&!mn(i)&&n.required)return!0;let t=e.type===`always`?e.target:e.cases.find(e=>_e({answer:i,condition:e}))?.target??e.default;return t.type===`end`?!1:t.type===`next`?!r:!0},[i,r,n.required,n.routingLogic]),l=z(()=>n.properties.buttonLabel?n.properties.buttonLabel:c?!n.required&&!mn(i)?`Skip`:`Next`:`Submit`,[i,c,n.properties.buttonLabel,n.required]),u=L(()=>{switch(n.properties.type){case`statement`:if(n.properties.buttonUrl&&typeof window<`u`){let e=w.safeParse(n.properties.buttonUrl).data;e&&window.open(e,`_blank`)}return e(void 0);default:return e(i)}},[i,e,n.properties]),d=z(()=>{switch(n.properties.type){case`rating`:case`single-select`:return!!n.properties.shouldAutoProgress;default:return!1}},[n.properties]);return W(H,{children:[t({onChange:L(t=>{a(t),d&&mn(t)&&o.safeParse(t).success&&e(t)},[d,o,e]),question:n,error:s}),(!d||!n.required)&&U(fn,{isDisabled:!!s,onPress:u,children:l})]})},gn=({isCompleted:e,onSubmit:t,children:n})=>W(H,{children:[n,e&&U(fn,{onPress:t})]}),_n=e=>U(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 44 38`,...e,children:W(`g`,{transform:`translate(-2 -2) scale(1.1)`,children:[U(`path`,{d:`M16.8395 3.2139C8.2208 3.9522 1.8331 11.5311 2.5721 20.1416C3.3111 28.7523 10.897 35.134 19.5157 34.3956L27.1631 33.7406C28.9787 33.585 30.6949 33.1248 32.2669 32.4163L38.7663 35.4396C39.3254 35.6994 39.9048 35.1205 39.6447 34.562L37.0707 29.0396C40.1147 25.8995 41.8336 21.5102 41.4304 16.8128C40.6913 8.2022 33.1054 1.8205 24.4867 2.5588L16.8395 3.2139Z`,fill:`#BAE6FD`}),U(`path`,{d:`M19.6764 24.0307C19.6764 24.0307 20.9773 25.4496 23.5438 25.1228C26.1103 24.7959 27.3642 23.0095 27.3642 23.0095`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`}),U(`path`,{d:`M18.0861 16.4082C18.0861 16.4082 17.1255 18.619 14.8183 18.9139C12.5111 19.2088 11.1697 17.237 11.1697 17.237`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`}),U(`path`,{d:`M32.6296 15.0398C32.6296 15.0398 31.6691 17.2506 29.3619 17.5455C27.0548 17.8404 25.7132 15.8686 25.7132 15.8686`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`})]})}),vn=({onClick:e,isWidgetOpen:t,classNames:n,label:r=`Help us improve`})=>t?null:W(E,{onPress:e,className:G(`confetti-trigger`,n?.trigger),children:[U(`span`,{className:G(`confetti-trigger-icon-wrapper`,n?.iconWrapper),"aria-hidden":!0,children:U(_n,{className:G(`confetti-trigger-icon`,n?.icon),width:24})}),U(`span`,{className:G(`confetti-trigger-label`,n?.label),children:r})]}),yn=({trigger:e,children:n,publishableKey:r,surveyId:i})=>{let a=s(),[o,c]=V(!1),[l,u]=V(!1);if(!a.isVisible)return null;let d=()=>{c(!1)};return W(H,{children:[e({onClick:()=>c(!0),isWidgetOpen:o,hasSubmitted:l}),o&&U(t.Provider,{value:{...a,dismiss:()=>{a.dismiss(),d()},submit:async e=>{let t=await a.submit(e);return u(!0),t}},children:n({onDismiss:d,surveyId:i,publishableKey:r})})]})},bn=({trigger:e=e=>U(vn,{...e}),children:t,...n})=>U(ye,{fallback:U(H,{}),children:U(b,{...n,alwaysRenderChildren:!0,children:U(yn,{trigger:e,surveyId:n.surveyId,publishableKey:n.publishableKey,children:t})})}),xn=e=>U(Pe,{...e,shouldAutoSubmit:!1,children:({questions:e,update:t,isCompleted:n,submit:r,isSubmitted:i,errors:a})=>i?U(Q,{}):U(gn,{onSubmit:r,isCompleted:n,children:e.filter(({visible:e})=>!!e).map(e=>U($,{question:e,error:a[e.id]||``,onChange:n=>t({question:e.position,answer:n})},e.position))})}),Sn=({onDismiss:e,closeOnFinishMs:t,isDismissable:n,...r})=>U(ye,{fallback:U(H,{}),children:U(b,{...r,children:U(de,{onDismiss:e,closeOnFinishMs:t,isDismissable:n,children:({setIsFinished:e})=>U(Ne,{...r,shouldAutoSubmit:!1,onFinished:()=>{e(),r.onFinished?.()},children:({questions:e,update:t,isCompleted:n,errors:r,submit:i,isSubmitted:a})=>a?U(Q,{}):U(gn,{onSubmit:i,isCompleted:n,children:e.filter(({visible:e})=>!!e).map(e=>U($,{question:e,error:r[e.id]||``,onChange:n=>t({question:e.position,answer:n})},e.position))})})})})}),Cn=({onDismiss:e,closeOnFinishMs:t,...n})=>U(ye,{fallback:U(H,{}),children:U(b,{...n,children:U(It,{onDismiss:e,closeOnFinishMs:t,children:({setIsFinished:e})=>U(Ne,{shouldAutoSubmit:!0,...n,onFinished:()=>{e(),n.onFinished?.()},children:({current:e,questions:t,update:n,isSubmitted:r})=>{let i=e===t.length-1;if(r)return U(Q,{});let a=t[e];return a?U(hn,{isLastQuestion:i,question:a,onSubmit:t=>n({question:e,answer:t}),children:e=>U($,{...e})}):U(H,{})}})})})}),wn=e=>U(Pe,{...e,shouldAutoSubmit:!0,children:({current:e,questions:t,update:n,isSubmitted:r})=>{let i=e===t.length-1;if(r)return U(Q,{});let a=t[e];return a?U(hn,{isLastQuestion:i,question:a,onSubmit:t=>n({question:e,answer:t}),children:e=>U($,{...e})}):U(H,{})}}),Tn=({delay:e})=>{let[t,n]=V(!1),r=z(()=>e,[]);return R(()=>{let e=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(e)},[]),{isVisible:t}},En=({visits:e,respondent:t})=>{let[n,r]=Ce(`cfti:${z(()=>window.location.pathname,[])}:visits:${t??``}`,0);return R(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:L(()=>r(0),[r])}},Dn=({visits:e,respondent:t})=>{let[n,r]=we(`cfti:${z(()=>window.location.pathname,[])}:visits:${t??``}`,0);return R(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:L(()=>r(0),[r])}},On=({threshold:e})=>{let[t,n]=V(()=>typeof window>`u`?!1:window.scrollY>=e);return R(()=>{let t=()=>{window.scrollY>=e&&n(!0)};return window.addEventListener(`scroll`,t,{passive:!0}),()=>window.removeEventListener(`scroll`,t)},[e]),{isVisible:t}};export{ue as CloseButton,Pe as Confetti,t as ConfettiContext,Ne as ConfettiController,b as ConfettiProvider,bn as ConfettiTrigger,_n as ConfettiTriggerIcon,vn as DefaultConfettiTrigger,gn as Embed,xn as EmbeddedConfetti,hn as Flow,Kt as FreeText,Sn as ModalConfetti,de as ModalContainer,Yt as MultiChoice,Cn as PopoverConfetti,It as PopoverContainer,cn as Rating,un as SingleChoice,dn as Statement,wn as StepperConfetti,$ as SurveyQuestionFactory,Q as ThankYouMessage,s as useConfetti,Tn as useVisibleAfterDelay,En as useVisibleAfterPageVisits,On as useVisibleAfterScroll,Dn as useVisibleAfterSessionPageVisits};
1
+ import{a as e,n as t,o as n,r,t as i}from"./internals-Dzl6abGJ.js";import{A as a,B as o,C as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,O as y,P as b,Q as x,R as S,S as C,T as w,U as T,V as E,W as D,X as O,Y as ee,Z as k,_ as A,a as j,b as M,c as te,d as ne,f as re,g as ie,h as ae,i as oe,j as N,k as se,l as ce,m as le,o as ue,p as de,q as fe,r as pe,s as P,t as me,u as he,v as ge,w as F,x as I,y as _e,z as ve}from"./ModalContainer-b9Zgg8fN.js";import{ErrorBoundary as ye}from"react-error-boundary";import L,{Suspense as be,createContext as R,forwardRef as z,lazy as xe,useCallback as B,useContext as Se,useEffect as V,useMemo as H,useRef as U,useState as W}from"react";import{useLocalStorage as Ce,useSessionStorage as we,useTimeout as Te}from"usehooks-ts";import{Fragment as G,jsx as K,jsxs as q}from"react/jsx-runtime";import J from"clsx";import{flushSync as Ee}from"react-dom";function De(e){return e.issues[0]?.message??`Invalid input`}const Y={rating:({scale:e},t)=>fe({scale:e},t),"open-ended":({max:e},t)=>h({maxLength:e},t),"single-select":({editable:e},t)=>m({maxLength:e?.max},t),"multi-select":({editable:e,max:t},n)=>d({maxLength:e?.max,maxSelected:t},n),statement:(e,t)=>ee(),"bug-report":(e,t)=>D({},t)},Oe=(e,t)=>{let n=e.type;switch(n){case`rating`:{let r=Y[n];return r(e,t)}case`open-ended`:{let r=Y[n];return r(e,t)}case`single-select`:{let r=Y[n];return r(e,t)}case`multi-select`:{let r=Y[n];return r(e,t)}case`statement`:{let r=Y[n];return r(e,t)}case`bug-report`:{let r=Y[n];return r(e,t)}default:throw Error(`Unsupported question type`)}},ke=({originalQuestions:e,answers:t,errors:r,pointer:i=-1})=>{if(!e)return{questions:[],currentIndex:-1};let a=e.sort((e,t)=>e.position-t.position).map(e=>{let t={...e},n=r[e.id];return n&&(t.error=n),{...t,visible:!1}});for(let e=0;e<a.length;e++){let r=a[e];if(!r)continue;let o=n({index:e,questions:a,answers:t});r.visible=i===e||o}let o=a.findIndex((e,n)=>n>i&&e.visible&&t[e.id]===void 0);return o===-1&&(o=a.findLastIndex(e=>!!e.visible)),{questions:a,currentIndex:o}},Ae=({questions:e,answers:t})=>{let n=je({questions:e,answers:t});return Object.fromEntries(Object.entries(n).filter(([,e])=>e!==null))},je=({questions:e,answers:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Me=({questions:e,errors:t})=>Object.fromEntries(Object.entries(t).filter(([t])=>!!e.find(e=>e.id===t)?.visible)),Ne=({current:e,shouldAutoSubmit:t,onFinished:n,children:r})=>{let{survey:a,submit:o}=f(),[s,c]=W({}),[l,u]=W({}),d=H(()=>ke({originalQuestions:a?.questions,answers:s,errors:l,pointer:e}),[a?.questions,s,l,e]),p=H(()=>!!d.questions.filter(({required:e,visible:t})=>!!e&&!!t).every(({id:e})=>s[e]!==void 0),[s,d.questions]),[m,h]=W(!1),g=B(({answers:e})=>{o({answers:e}).finally(()=>{n?.()})},[n,o]),_=B(()=>{g({answers:Ae({questions:d.questions,answers:s})}),h(!0)},[s,d.questions,g]),v=B(({question:n,answer:r})=>{let i=d.questions.at(n);if(!i)return{error:`Question index is invalid`};let o=Oe(i.properties,{required:i.required}).safeParse(r);if(!o.success){let e=De(o.error);return u(t=>{if(t[i.id]===e)return t;let n={...t};return n[i.id]=e,n}),c(e=>{if(!(i.id in e))return e;let t={...e};return delete t[i.id],t}),{error:e}}u(e=>{if(!e[i.id])return e;let t={...e};return delete t[i.id],t});let f=!i.required&&!r?null:r,p={...s};if(p[i.id]===f)return{next:ke({originalQuestions:a?.questions,answers:p,errors:l,pointer:e}).currentIndex};p[i.id]=f;let m=ke({originalQuestions:a?.questions,answers:p,errors:l,pointer:e});return p=je({questions:m.questions,answers:p}),c(p),u(Me({questions:m.questions,errors:l})),m.questions.filter(({visible:e})=>!!e).every(({id:e})=>p[e]!==void 0)&&t&&(g({answers:Ae({questions:m.questions,answers:p})}),h(!0)),{next:m.currentIndex}},[d.questions,s,a?.questions,l,t,e,g]);return d.questions.length===0?K(G,{}):K(`div`,{className:`confetti ${i}`,children:r({questions:d.questions,current:e??d.currentIndex,update:v,isCompleted:p,submit:_,isSubmitted:m,errors:l})})},Pe=({children:e,onFinished:t,shouldAutoSubmit:n,...r})=>K(ye,{fallback:K(G,{}),children:K(E,{...r,children:K(Ne,{shouldAutoSubmit:n,onFinished:t,children:e})})});function Fe(e,t,n){let r=c(e=>{n&&!e.defaultPrevented&&n(t)});V(()=>{let t=e?.current?.form;return t?.addEventListener(`reset`,r),()=>{t?.removeEventListener(`reset`,r)}},[e])}function Ie(e){let{id:t,label:n,"aria-labelledby":r,"aria-label":i,labelElementType:a=`label`}=e;t=p(t);let o=p(),s={};n&&(r=r?`${o} ${r}`:o,s={id:o,htmlFor:a===`label`?t:void 0});let c=se({id:t,"aria-label":i,"aria-labelledby":r});return{labelProps:s,fieldProps:c}}function Le(e){let{description:t,errorMessage:n,isInvalid:r,validationState:i}=e,{labelProps:a,fieldProps:o}=Ie(e),s=u([!!t,!!n,r,i]),c=u([!!t,!!n,r,i]);return o=N(o,{"aria-describedby":[s,c,e[`aria-describedby`]].filter(Boolean).join(` `)||void 0}),{labelProps:a,fieldProps:o,descriptionProps:{id:s},errorMessageProps:{id:c}}}function Re(e,t,n){let{validationBehavior:r,focus:i}=e;g(()=>{if(r===`native`&&n?.current&&!n.current.disabled){let e=t.realtimeValidation.isInvalid?t.realtimeValidation.validationErrors.join(` `)||`Invalid value.`:``;n.current.setCustomValidity(e),n.current.hasAttribute(`title`)||(n.current.title=``),t.realtimeValidation.isInvalid||t.updateValidation(Be(n.current))}});let a=U(!1),o=c(()=>{a.current||t.resetValidation()}),s=c(e=>{t.displayValidation.isInvalid||t.commitValidation();let r=n?.current?.form;!e.defaultPrevented&&n&&r&&Ve(r)===n.current&&(i?i():n.current?.focus(),ie(`keyboard`)),e.preventDefault()}),l=c(()=>{t.commitValidation()});V(()=>{let e=n?.current;if(!e)return;let t=e.form,r=t?.reset;return t&&(t.reset=()=>{a.current=!window.event||window.event.type===`message`&&v(window.event)instanceof MessagePort,r?.call(t),a.current=!1}),e.addEventListener(`invalid`,s),e.addEventListener(`change`,l),t?.addEventListener(`reset`,o),()=>{e.removeEventListener(`invalid`,s),e.removeEventListener(`change`,l),t?.removeEventListener(`reset`,o),t&&(t.reset=r)}},[n,r])}function ze(e){let t=e.validity;return{badInput:t.badInput,customError:t.customError,patternMismatch:t.patternMismatch,rangeOverflow:t.rangeOverflow,rangeUnderflow:t.rangeUnderflow,stepMismatch:t.stepMismatch,tooLong:t.tooLong,tooShort:t.tooShort,typeMismatch:t.typeMismatch,valueMissing:t.valueMissing,valid:t.valid}}function Be(e){return{isInvalid:!e.validity.valid,validationDetails:ze(e),validationErrors:e.validationMessage?[e.validationMessage]:[]}}function Ve(e){for(let t=0;t<e.elements.length;t++){let n=e.elements[t];if(n.validity?.valid===!1)return n}return null}const He={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!0},Ue={...He,customError:!0,valid:!1},X={isInvalid:!1,validationDetails:He,validationErrors:[]},We=R({}),Ge=`__reactAriaFormValidationState`;function Z(e){if(e[Ge]){let{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}=e[Ge];return{realtimeValidation:t,displayValidation:n,updateValidation:r,resetValidation:i,commitValidation:a}}return Ke(e)}function Ke(e){let{isInvalid:t,validationState:n,name:r,value:i,builtinValidation:a,validate:o,validationBehavior:s=`aria`}=e;n&&(t||=n===`invalid`);let c=t===void 0?null:{isInvalid:t,validationErrors:[],validationDetails:Ue},l=H(()=>!o||i==null?null:Ye(Je(o,i)),[o,i]);a?.validationDetails.valid&&(a=void 0);let u=Se(We),d=H(()=>r?Array.isArray(r)?r.flatMap(e=>qe(u[e])):qe(u[r]):[],[u,r]),[f,p]=W(u),[m,h]=W(!1);u!==f&&(p(u),h(!1));let g=H(()=>Ye(m?[]:d),[m,d]),_=U(X),[v,y]=W(X),b=U(X),x=()=>{if(!S)return;C(!1);let e=l||a||_.current;Xe(e,b.current)||(b.current=e,y(e))},[S,C]=W(!1);return V(x),{realtimeValidation:c||g||l||a||X,displayValidation:s===`native`?c||g||v:c||g||l||a||v,updateValidation(e){s===`aria`&&!Xe(v,e)?y(e):_.current=e},resetValidation(){let e=X;Xe(e,b.current)||(b.current=e,y(e)),s===`native`&&C(!1),h(!0)},commitValidation(){s===`native`&&C(!0),h(!0)}}}function qe(e){return e?Array.isArray(e)?e:[e]:[]}function Je(e,t){if(typeof e==`function`){let n=e(t);if(n&&typeof n!=`boolean`)return qe(n)}return[]}function Ye(e){return e.length?{isInvalid:!0,validationErrors:e,validationDetails:Ue}:null}function Xe(e,t){return e===t?!0:!!e&&!!t&&e.isInvalid===t.isInvalid&&e.validationErrors.length===t.validationErrors.length&&e.validationErrors.every((e,n)=>e===t.validationErrors[n])&&Object.entries(e.validationDetails).every(([e,n])=>t.validationDetails[e]===n)}function Ze(...e){let t=new Set,n=!1,r={...He};for(let i of e){for(let e of i.validationErrors)t.add(e);for(let e in n||=i.isInvalid,r)r[e]||=i.validationDetails[e]}return r.valid=!n,{isInvalid:n,validationErrors:[...t],validationDetails:r}}function Qe(e,t){let{inputElementType:n=`input`,isDisabled:r=!1,isRequired:i=!1,isReadOnly:o=!1,type:s=`text`,validationBehavior:c=`aria`}=e,[l,u]=de(e.value,e.defaultValue||``,e.onChange),{focusableProps:d}=le(e,t),f=Z({...e,value:l}),{isInvalid:p,validationErrors:m,validationDetails:h}=f.displayValidation,{labelProps:g,fieldProps:_,descriptionProps:y,errorMessageProps:b}=Le({...e,isInvalid:p,errorMessage:e.errorMessage||m}),x=a(e,{labelable:!0}),S={type:s,pattern:e.pattern},[C]=W(l);return Fe(t,e.defaultValue??C,u),Re(e,f,t),{labelProps:g,inputProps:N(x,n===`input`?S:void 0,{disabled:r,readOnly:o,required:i&&c===`native`,"aria-required":i&&c===`aria`||void 0,"aria-invalid":p||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-activedescendant":e[`aria-activedescendant`],"aria-autocomplete":e[`aria-autocomplete`],"aria-haspopup":e[`aria-haspopup`],"aria-controls":e[`aria-controls`],value:l,onChange:e=>u(v(e).value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,form:e.form,placeholder:e.placeholder,inputMode:e.inputMode,autoCorrect:e.autoCorrect,spellCheck:e.spellCheck,[parseInt(L.version,10)>=17?`enterKeyHint`:`enterkeyhint`]:e.enterKeyHint,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...d,..._}),descriptionProps:y,errorMessageProps:b,isInvalid:p,validationErrors:m,validationDetails:h}}function $e(e,t,n){let{isDisabled:r=!1,isReadOnly:i=!1,value:o,name:s,form:c,children:l,"aria-label":u,"aria-labelledby":d,validationState:f=`valid`,isInvalid:p,onPressStart:m,onPressEnd:h,onPressChange:g,onPress:_,onPressUp:y,onClick:b}=e,x=e=>{e.stopPropagation(),t.setSelected(v(e).checked)},{pressProps:S,isPressed:C}=A({onPressStart:m,onPressEnd:h,onPressChange:g,onPress:_,onPressUp:y,onClick:b,isDisabled:r}),{pressProps:w,isPressed:T}=A({onPressStart:m,onPressEnd:h,onPressChange:g,onPressUp:y,onClick:b,onPress(e){_?.(e),t.toggle(),n.current?.focus()},isDisabled:r||i}),{focusableProps:E}=le(e,n),D=N(S,E),O=a(e,{labelable:!0});return Fe(n,t.defaultSelected,t.setSelected),{labelProps:N(w,{onClick:e=>e.preventDefault()}),inputProps:N(O,{"aria-invalid":p||f===`invalid`||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-controls":e[`aria-controls`],"aria-readonly":i||void 0,onChange:x,disabled:r,...o==null?{}:{value:o},name:s,form:c,type:`checkbox`,...D}),isSelected:t.isSelected,isPressed:C||T,isDisabled:r,isReadOnly:i,isInvalid:p||f===`invalid`}}function et(e,t,n){let r=Z({...e,value:t.isSelected}),{isInvalid:i,validationErrors:a,validationDetails:o}=r.displayValidation,{labelProps:s,inputProps:c,isSelected:l,isPressed:u,isDisabled:d,isReadOnly:f}=$e({...e,isInvalid:i},t,n);Re(e,r,n);let{isIndeterminate:p,isRequired:m,validationBehavior:h=`aria`}=e;V(()=>{n.current&&(n.current.indeterminate=!!p)});let{pressProps:g}=A({isDisabled:d||f,onPress(){let{[Ge]:t}=e,{commitValidation:n}=t||r;n()}});return{labelProps:N(s,g,H(()=>({onMouseDown:e=>e.preventDefault()}),[])),inputProps:{...c,checked:l,"aria-required":m&&h===`aria`||void 0,required:m&&h===`native`},isSelected:l,isPressed:u,isDisabled:d,isReadOnly:f,isInvalid:i,validationErrors:a,validationDetails:o}}const tt=new WeakMap;function nt(e,t){let{isDisabled:n,name:r,form:i,validationBehavior:o=`aria`}=e,{isInvalid:s,validationErrors:c,validationDetails:l}=t.displayValidation,{labelProps:u,fieldProps:d,descriptionProps:f,errorMessageProps:p}=Le({...e,labelElementType:`span`,isInvalid:s,errorMessage:e.errorMessage||c});tt.set(t,{name:r,form:i,descriptionId:f.id,errorMessageId:p.id,validationBehavior:o});let m=a(e,{labelable:!0}),{focusWithinProps:h}=re({onBlurWithin:e.onBlur,onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange});return{groupProps:N(m,{role:`group`,"aria-disabled":n||void 0,...d,...h}),labelProps:u,descriptionProps:f,errorMessageProps:p,isInvalid:s,validationErrors:c,validationDetails:l}}function rt(e={}){let{isReadOnly:t}=e,[n,r]=de(e.isSelected,e.defaultSelected||!1,e.onChange),[i]=W(n);function a(e){t||r(e)}function o(){t||r(!n)}return{isSelected:n,defaultSelected:e.defaultSelected??i,setSelected:a,toggle:o}}function it(e,t,n){let r=rt({isReadOnly:e.isReadOnly||t.isReadOnly,isSelected:t.isSelected(e.value),defaultSelected:t.defaultValue.includes(e.value),onChange(n){n?t.addValue(e.value):t.removeValue(e.value),e.onChange&&e.onChange(n)}}),{name:i,form:a,descriptionId:o,errorMessageId:s,validationBehavior:c}=tt.get(t);c=e.validationBehavior??c;let{realtimeValidation:l}=Z({...e,value:r.isSelected,name:void 0,validationBehavior:`aria`}),u=U(X),d=()=>{t.setInvalid(e.value,l.isInvalid?l:u.current)};V(d);let f=t.realtimeValidation.isInvalid?t.realtimeValidation:l,p=c===`native`?t.displayValidation:f,m=et({...e,isReadOnly:e.isReadOnly||t.isReadOnly,isDisabled:e.isDisabled||t.isDisabled,name:e.name||i,form:e.form||a,isRequired:e.isRequired??t.isRequired,validationBehavior:c,[Ge]:{realtimeValidation:f,displayValidation:p,resetValidation:t.resetValidation,commitValidation:t.commitValidation,updateValidation(e){u.current=e,d()}}},r,n);return{...m,inputProps:{...m.inputProps,"aria-describedby":[e[`aria-describedby`],t.isInvalid?s:null,o].filter(Boolean).join(` `)||void 0}}}const at=new WeakMap;function ot(e,t,n){let{value:r,children:i,"aria-label":o,"aria-labelledby":s,onPressStart:c,onPressEnd:l,onPressChange:u,onPress:d,onPressUp:f,onClick:p}=e,m=e.isDisabled||t.isDisabled,h=t.selectedValue===r,g=e=>{e.stopPropagation(),t.setSelectedValue(r)},{pressProps:_,isPressed:v}=A({onPressStart:c,onPressEnd:l,onPressChange:u,onPress:d,onPressUp:f,onClick:p,isDisabled:m}),{pressProps:y,isPressed:b}=A({onPressStart:c,onPressEnd:l,onPressChange:u,onPressUp:f,onClick:p,isDisabled:m,onPress(e){d?.(e),t.setSelectedValue(r),n.current?.focus()}}),{focusableProps:x}=le(N(e,{onFocus:()=>t.setLastFocusedValue(r)}),n),S=N(_,x),C=a(e,{labelable:!0}),w=-1;t.selectedValue==null?(t.lastFocusedValue===r||t.lastFocusedValue==null)&&(w=0):t.selectedValue===r&&(w=0),m&&(w=void 0);let{name:T,form:E,descriptionId:D,errorMessageId:O,validationBehavior:ee}=at.get(t);return Fe(n,t.defaultSelectedValue,t.setSelectedValue),Re({validationBehavior:ee},t,n),{labelProps:N(y,H(()=>({onClick:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault()}),[])),inputProps:N(C,{...S,type:`radio`,name:T,form:E,tabIndex:w,disabled:m,required:t.isRequired&&ee===`native`,checked:h,value:r,onChange:g,"aria-describedby":[e[`aria-describedby`],t.isInvalid?O:null,D].filter(Boolean).join(` `)||void 0}),isDisabled:m,isSelected:h,isPressed:v||b}}function st(e,t){let{name:n,form:r,isReadOnly:i,isRequired:o,isDisabled:s,orientation:c=`vertical`,validationBehavior:l=`aria`}=e,{direction:u}=ge(),{isInvalid:d,validationErrors:f,validationDetails:m}=t.displayValidation,{labelProps:h,fieldProps:g,descriptionProps:_,errorMessageProps:y}=Le({...e,labelElementType:`span`,isInvalid:t.isInvalid,errorMessage:e.errorMessage||f}),x=a(e,{labelable:!0}),{focusWithinProps:S}=re({onBlurWithin(n){e.onBlur?.(n),t.selectedValue||t.setLastFocusedValue(null)},onFocusWithin:e.onFocus,onFocusWithinChange:e.onFocusChange}),C=e=>{let n;switch(e.key){case`ArrowRight`:n=u===`rtl`&&c!==`vertical`?`prev`:`next`;break;case`ArrowLeft`:n=u===`rtl`&&c!==`vertical`?`next`:`prev`;break;case`ArrowDown`:n=`next`;break;case`ArrowUp`:n=`prev`;break;default:return}e.preventDefault();let r=ae(e.currentTarget,{from:v(e),accept:e=>e instanceof b(e).HTMLInputElement&&e.type===`radio`}),i;n===`next`?(i=r.nextNode(),i||=(r.currentNode=e.currentTarget,r.firstChild())):(i=r.previousNode(),i||=(r.currentNode=e.currentTarget,r.lastChild())),i&&(i.focus(),t.setSelectedValue(i.value))},w=p(n);return at.set(t,{name:w,form:r,descriptionId:_.id,errorMessageId:y.id,validationBehavior:l}),{radioGroupProps:N(x,{role:`radiogroup`,onKeyDown:C,"aria-invalid":t.isInvalid||void 0,"aria-errormessage":e[`aria-errormessage`],"aria-readonly":i||void 0,"aria-required":o||void 0,"aria-disabled":s||void 0,"aria-orientation":c,...g,...S}),labelProps:h,descriptionProps:_,errorMessageProps:y,isInvalid:d,validationErrors:f,validationDetails:m}}const ct=R({}),Q=z(function(e,t){[e,t]=M(e,t,ct);let{elementType:n=`span`,...r}=e,i=F[n];return L.createElement(i,{className:`react-aria-Text`,...r,ref:t})});function lt(e={}){let[t,n]=de(e.value,e.defaultValue||[],e.onChange),[r]=W(t),i=!!e.isRequired&&t.length===0,a=U(new Map),o=Z({...e,value:t}),s=o.displayValidation.isInvalid;return{...o,value:t,defaultValue:e.defaultValue??r,setValue(t){e.isReadOnly||e.isDisabled||n(t)},isDisabled:e.isDisabled||!1,isReadOnly:e.isReadOnly||!1,isSelected(e){return t.includes(e)},addValue(t){e.isReadOnly||e.isDisabled||n(e=>e.includes(t)?e:e.concat(t))},removeValue(r){e.isReadOnly||e.isDisabled||t.includes(r)&&n(t.filter(e=>e!==r))},toggleValue(r){e.isReadOnly||e.isDisabled||(t.includes(r)?n(t.filter(e=>e!==r)):n(t.concat(r)))},setInvalid(e,t){let n=new Map(a.current);t.isInvalid?n.set(e,t):n.delete(e),a.current=n,o.updateValidation(Ze(...n.values()))},validationState:e.validationState??(s?`invalid`:null),isInvalid:s,isRequired:i}}let ut=Math.round(Math.random()*1e10),dt=0;function ft(e){let t=H(()=>e.name||`radio-group-${ut}-${++dt}`,[e.name]),[n,r]=de(e.value,e.defaultValue??null,e.onChange),[i]=W(n),[a,o]=W(null),s=Z({...e,value:n}),c=t=>{!e.isReadOnly&&!e.isDisabled&&(r(t),s.commitValidation())},l=s.displayValidation.isInvalid;return{...s,name:t,selectedValue:n,defaultSelectedValue:e.value===void 0?e.defaultValue??null:i,setSelectedValue:c,lastFocusedValue:a,setLastFocusedValue:o,isDisabled:e.isDisabled||!1,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1,validationState:e.validationState||(l?`invalid`:null),isInvalid:l}}const pt=R(null),mt=z(function(e,t){return Se(pt)?.isInvalid?L.createElement(ht,{...e,ref:t}):null}),ht=z((e,t)=>{let n=Se(pt),r=a(e,{global:!0}),i=I({...e,defaultClassName:`react-aria-FieldError`,defaultChildren:n.validationErrors.length===0?void 0:n.validationErrors.join(` `),values:n});return i.children==null?null:L.createElement(Q,{slot:`errorMessage`,...r,...i,ref:t})}),gt=R(null),_t=R(null),vt=R(null),yt=z(function(e,t){[e,t]=M(e,t,_t);let{validationBehavior:n}=l(gt)||{},r=e.validationBehavior??n??`native`,i=lt({...e,validationBehavior:r}),[o,s]=C(!e[`aria-label`]&&!e[`aria-labelledby`]),{groupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=nt({...e,label:s,validationBehavior:r},i),m=I({...e,values:{isDisabled:i.isDisabled,isReadOnly:i.isReadOnly,isRequired:e.isRequired||!1,isInvalid:i.isInvalid,state:i},defaultClassName:`react-aria-CheckboxGroup`}),h=a(e,{global:!0});return L.createElement(F.div,{...N(h,m,c),ref:t,slot:e.slot||void 0,"data-readonly":i.isReadOnly||void 0,"data-required":e.isRequired||void 0,"data-invalid":i.isInvalid||void 0,"data-disabled":e.isDisabled||void 0},L.createElement(_e,{values:[[vt,i],[ue,{...u,ref:o,elementType:`span`}],[ct,{slots:{description:d,errorMessage:f}}],[pt,p]]},m.children))}),bt=z(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=M(r,t,ve);let{validationBehavior:i}=l(gt)||{},o=e.validationBehavior??i??`native`,s=Se(vt),c=y(H(()=>_(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:u,inputProps:d,isSelected:f,isDisabled:p,isReadOnly:m,isPressed:h,isInvalid:g}=s?it({...w(e),value:e.value,children:typeof e.children==`function`?!0:e.children},s,c):et({...w(e),children:typeof e.children==`function`?!0:e.children,validationBehavior:o},rt(e),c),{isFocused:v,isFocusVisible:b,focusProps:x}=ne(),S=p||m,{hoverProps:C,isHovered:T}=he({...e,isDisabled:S}),E=I({...e,defaultClassName:`react-aria-Checkbox`,values:{isSelected:f,isIndeterminate:e.isIndeterminate||!1,isPressed:h,isHovered:T,isFocused:v,isFocusVisible:b,isDisabled:p,isReadOnly:m,isInvalid:g,isRequired:e.isRequired||!1}}),D=a(e,{global:!0});return delete D.id,delete D.onClick,L.createElement(F.label,{...N(D,u,C,E),ref:t,slot:e.slot||void 0,"data-selected":f||void 0,"data-indeterminate":e.isIndeterminate||void 0,"data-pressed":h||void 0,"data-hovered":T||void 0,"data-focused":v||void 0,"data-focus-visible":b||void 0,"data-disabled":p||void 0,"data-readonly":m||void 0,"data-invalid":g||void 0,"data-required":e.isRequired||void 0},L.createElement(te,{elementType:`span`},L.createElement(`input`,{...N(d,x),ref:c})),E.children)}),xt=R({}),St=R({});let Ct=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const wt=ce(function(e,t){[e,t]=M(e,t,St);let{hoverProps:n,isHovered:r}=he({...e,isDisabled:e.disabled}),{isFocused:i,isFocusVisible:a,focusProps:o}=ne({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=I({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-Input`});return L.createElement(F.input,{...N(Ct(e),o,n),...c,ref:t,"data-focused":i||void 0,"data-disabled":e.disabled||void 0,"data-hovered":r||void 0,"data-focus-visible":a||void 0,"data-invalid":s||void 0})}),Tt=R(null);function Et(e){let t=U({});return L.createElement(Tt.Provider,{value:t},e.children)}const Dt=R({isSelected:!1}),Ot=R(null),kt=R(null),At=R(null),jt=z(function(e,t){[e,t]=M(e,t,Ot);let{validationBehavior:n}=l(gt)||{},r=e.validationBehavior??n??`native`,i=ft({...e,validationBehavior:r}),[o,s]=C(!e[`aria-label`]&&!e[`aria-labelledby`]),{radioGroupProps:c,labelProps:u,descriptionProps:d,errorMessageProps:f,...p}=st({...e,label:s,validationBehavior:r},i),m=I({...e,values:{orientation:e.orientation||`vertical`,isDisabled:i.isDisabled,isReadOnly:i.isReadOnly,isRequired:i.isRequired,isInvalid:i.isInvalid,state:i},defaultClassName:`react-aria-RadioGroup`}),h=a(e,{global:!0});return L.createElement(F.div,{...N(h,m,c),ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||`vertical`,"data-invalid":i.isInvalid||void 0,"data-disabled":i.isDisabled||void 0,"data-readonly":i.isReadOnly||void 0,"data-required":i.isRequired||void 0},L.createElement(_e,{values:[[At,i],[ue,{...u,ref:o,elementType:`span`}],[ct,{slots:{description:d,errorMessage:f}}],[pt,p]]},L.createElement(Et,null,m.children)))}),Mt=z(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=M(r,t,kt);let i=L.useContext(At),o=y(H(()=>_(n,e.inputRef===void 0?null:e.inputRef),[n,e.inputRef])),{labelProps:s,inputProps:c,isSelected:l,isDisabled:u,isPressed:d}=ot({...w(e),children:typeof e.children==`function`?!0:e.children},i,o),{isFocused:f,isFocusVisible:p,focusProps:m}=ne(),h=u||i.isReadOnly,{hoverProps:g,isHovered:v}=he({...e,isDisabled:h}),b=I({...e,defaultClassName:`react-aria-Radio`,values:{isSelected:l,isPressed:d,isHovered:v,isFocused:f,isFocusVisible:p,isDisabled:u,isReadOnly:i.isReadOnly,isInvalid:i.isInvalid,isRequired:i.isRequired}}),x=a(e,{global:!0});return delete x.id,delete x.onClick,L.createElement(F.label,{...N(x,s,g,b),ref:t,"data-selected":l||void 0,"data-pressed":d||void 0,"data-hovered":v||void 0,"data-focused":f||void 0,"data-focus-visible":p||void 0,"data-disabled":u||void 0,"data-readonly":i.isReadOnly||void 0,"data-invalid":i.isInvalid||void 0,"data-required":i.isRequired||void 0},L.createElement(te,{elementType:`span`},L.createElement(`input`,{...N(c,m),ref:o})),L.createElement(Dt.Provider,{value:{isSelected:l}},b.children))}),Nt=R({});let Pt=e=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...i}=e;return i};const Ft=z(function(e,t){[e,t]=M(e,t,Nt);let{hoverProps:n,isHovered:r}=he(e),{isFocused:i,isFocusVisible:a,focusProps:o}=ne({isTextInput:!0,autoFocus:e.autoFocus}),s=!!e[`aria-invalid`]&&e[`aria-invalid`]!==`false`,c=I({...e,values:{isHovered:r,isFocused:i,isFocusVisible:a,isDisabled:e.disabled||!1,isInvalid:s},defaultClassName:`react-aria-TextArea`});return L.createElement(F.textarea,{...N(Pt(e),o,n),...c,ref:t,"data-focused":i||void 0,"data-disabled":e.disabled||void 0,"data-hovered":r||void 0,"data-focus-visible":a||void 0,"data-invalid":s||void 0})}),It=R(null),Lt=ce(function(e,t){[e,t]=M(e,t,It);let{validationBehavior:n}=l(gt)||{},r=e.validationBehavior??n??`native`,i=U(null);[e,i]=M(e,i,S);let[o,s]=C(!e[`aria-label`]&&!e[`aria-labelledby`]),[c,u]=W(`input`),{labelProps:d,inputProps:f,descriptionProps:p,errorMessageProps:m,...h}=Qe({...w(e),inputElementType:c,label:s,validationBehavior:r},i),g=B(e=>{i.current=e,e&&u(e instanceof HTMLTextAreaElement?`textarea`:`input`)},[i]),_=I({...e,values:{isDisabled:e.isDisabled||!1,isInvalid:h.isInvalid,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1},defaultClassName:`react-aria-TextField`}),v=a(e,{global:!0});return delete v.id,L.createElement(F.div,{...v,..._,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-invalid":h.isInvalid||void 0,"data-readonly":e.isReadOnly||void 0,"data-required":e.isRequired||void 0},L.createElement(_e,{values:[[ue,{...d,ref:o}],[St,{...f,ref:g}],[Nt,{...f,ref:g}],[xt,{role:`presentation`,isInvalid:h.isInvalid,isDisabled:e.isDisabled||!1}],[ct,{slots:{description:p,errorMessage:m}}],[pt,h]]},_.children))}),Rt=({title:e,description:t,classNames:n})=>{let{survey:r,dismiss:i}=f();if(!r)return null;let a=t||r.confirmation.description;return q(G,{children:[K(`div`,{className:J(`cf-question`,n?.question),children:q(`div`,{className:J(`cf-header`,n?.header),children:[K(P,{className:J(`cf-title`,n?.title),children:e||r.confirmation.title||`Feedback submitted!`}),a&&K(Q,{slot:`description`,className:J(`cf-description`,n?.description),children:a})]})}),K(j,{className:`cf-submit-button`,onPress:i,children:r.confirmation.buttonText||`Close`})]})},zt=({children:e,classNames:t,containerProps:n,onDismiss:r,closeOnFinishMs:a=3e3})=>{let{surveyId:o,survey:s,dismiss:c}=f(),[l,u]=W(!1),[d,p]=W(!1),[m,h]=W(!1);return Te(()=>{s&&c()},l&&!(d||m)?a:null),q(`div`,{className:J(`confetti-dialog ${i}`,t?.dialog),id:`${o}-popover`,...n,onMouseEnter:e=>{n?.onMouseEnter?.(e),p(!0)},onMouseLeave:e=>{n?.onMouseLeave?.(e),p(!1)},onFocusCapture:e=>{n?.onFocusCapture?.(e),h(!0)},onBlurCapture:e=>{n?.onBlurCapture?.(e),e.currentTarget.contains(e.relatedTarget)||h(!1)},children:[K(pe,{className:J(`confetti-dialog-close`,t?.closeButton),iconClassName:t?.icon,onClose:async()=>{await c(),r?.()}}),typeof e==`function`?e({setIsFinished:()=>u(!0)}):e]})},Bt=3e4;Bt/1e3;const Vt=({maskAllInputs:e}={})=>{let[n,a]=W(null),[o,s]=W(!1),[c,l]=W(null),[u,d]=W(30),f=U(null),p=U(null),m=U(null),h=U([]);V(()=>{let e=new CustomEvent(r,{detail:{isRecording:o}});document.dispatchEvent(e)},[o]);let g=B(()=>{p.current&&=(clearInterval(p.current),null),m.current&&=(clearTimeout(m.current),null),f.current=null,d(Bt/1e3)},[]),_=B(()=>{f.current?.(),g(),s(!1),a(JSON.stringify(h.current))},[g]);return{recordingEventsJson:n,isRecording:o,recordingError:c,remainingSeconds:u,startRecording:B(async()=>{s(!0),l(null),a(null),h.current=[];try{let{record:n}=await import(`./record-CeeyzJpB.js`);f.current=n({slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0},sampling:{mousemove:50,scroll:100,input:`last`},emit:e=>{h.current.push(e)},blockClass:i,maskTextClass:t,maskAllInputs:e})??null;let r=Bt/1e3;d(r),p.current=setInterval(()=>{--r,d(r)},1e3),m.current=setTimeout(()=>{_()},Bt)}catch{l(`Failed to start recording. Please try again.`),s(!1),g()}},[e,_,g]),stopRecording:_,clear:B(()=>{g(),s(!1),a(null),l(null),h.current=[]},[g])}},Ht=e=>e.replace(/\S/g,`*`),Ut=e=>`*`.repeat(e.length),Wt=(e,t)=>{for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t(n):Wt(n,t)},Gt=e=>{if(e instanceof HTMLInputElement)e.setAttribute(`value`,Ut(e.getAttribute(`value`)??``));else if(e instanceof HTMLTextAreaElement)e.textContent=Ut(e.textContent);else if(e instanceof HTMLSelectElement)for(let t of e.querySelectorAll(`option`))t.textContent=Ut(t.textContent)},Kt=({maskInputs:e})=>({name:`cfti-redact`,afterClone:n=>{let{clone:r}=n;if(r instanceof HTMLElement){for(let e of r.querySelectorAll(`.${t}`)){Wt(e,e=>{e.data=Ht(e.data)}),Gt(e);for(let t of e.querySelectorAll(`input, textarea, select`))Gt(t)}if(e)for(let e of r.querySelectorAll(`input, textarea, select`))Gt(e)}}}),qt=({maskAllInputs:e}={})=>{let[t,n]=W(null),[r,a]=W(!1),[o,s]=W(null);return{screenshotDataUrl:t,isCapturing:r,captureError:o,capture:B(async()=>{a(!0),s(null);try{let{snapdom:t}=await import(`./snapdom-VnBlM9vL.js`),r=await(await t(document.documentElement,{embedFonts:!0,exclude:[`.${i}`],excludeMode:`hide`,plugins:[Kt({maskInputs:!!e})],fast:!1})).toCanvas(),a=window.devicePixelRatio||1,o=Math.min(Math.round(window.innerWidth*a),r.width),s=Math.min(Math.round(window.innerHeight*a),r.height),c=document.createElement(`canvas`);c.width=o,c.height=s;let l=c.getContext(`2d`);if(!l)throw Error(`Failed to get 2D context for cropping`);l.drawImage(r,0,0,o,s,0,0,o,s),n(c.toDataURL(`image/png`))}catch{s(`Failed to capture screenshot. Please try again.`)}finally{a(!1)}},[e]),clear:B(()=>{n(null),s(null)},[])}},Jt=e=>q(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[K(`circle`,{cx:`12`,cy:`12`,r:`10`}),K(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`})]}),Yt=e=>q(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[K(`path`,{d:`M10 11v6`}),K(`path`,{d:`M14 11v6`}),K(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),K(`path`,{d:`M3 6h18`}),K(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})]});function Xt(){if(window.DD_RUM&&typeof window.DD_RUM?.getInternalContext==`function`&&typeof window.DD_RUM?.getSessionReplayLink==`function`)try{let e=window.DD_RUM?.getInternalContext?.(),t=window.DD_RUM?.getSessionReplayLink?.();return{sessionId:e?.session_id,sessionReplayLink:t}}catch{return null}return null}function Zt(){if(typeof window>`u`||typeof navigator>`u`)return;let e=navigator,t=window.screen,n=Xt();return{userAgent:e.userAgent,screenResolution:`${t.width}x${t.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,pageUrl:window.location.href,pageTitle:document.title,referrer:document.referrer,language:e.language,timestamp:new Date().toISOString(),datadogTraceId:n?.traceId,datadogSessionId:n?.sessionId,datadogSessionReplayLink:n?.sessionReplayLink}}const Qt=xe(()=>import(`./RecordingReplayer-CKYzAfYD.js`)),$t=({id:e,title:t,description:n,properties:r,onChange:i,required:a,error:o,classNames:s,maskAllInputs:c})=>{let l=H(()=>Zt(),[]),[u,d]=W(``),[f,p]=W(``),{screenshotDataUrl:m,isCapturing:h,captureError:g,capture:_,clear:v}=qt({maskAllInputs:c}),{recordingEventsJson:y,isRecording:b,recordingError:x,remainingSeconds:S,startRecording:C,stopRecording:w,clear:T}=Vt({maskAllInputs:c}),E=H(()=>({title:u,...f?{description:f}:{},...m?{screenshotDataUrl:m}:{},...y?{recordingEventsJson:y}:{},metadata:l}),[f,l,y,m,u]);V(()=>{i(E)},[E,i]),V(()=>()=>{w()},[w]);let D=H(()=>y?JSON.parse(y):[],[y]);return K(G,{children:b?q(j,{className:J(`cf-bug-report-button`,`cf-bug-report-record-button`,s?.button,s?.recordButton),onPress:w,children:[K(Jt,{}),q(`span`,{children:[30-S,`s /`,` `,30,`s`]})]}):q(`div`,{className:J(`cf-bug-report`,s?.base),children:[q(Lt,{isRequired:a,isInvalid:!!o,name:`${e}-title`,value:u,onChange:d,className:J(`cf-question`,s?.question),children:[q(`div`,{className:J(`cf-header`,s?.header),children:[q(P,{className:J(`cf-title`,s?.title),children:[t,!a&&q(`span`,{className:J(`cf-label-optional`,s?.optionalLabel),children:[` `,`(optional)`]})]}),n&&K(Q,{slot:`description`,className:J(`cf-description`,s?.description),children:n})]}),K(wt,{placeholder:r.placeholder||`Brief description of the issue`,className:J(`cf-input`,s?.input)})]}),q(Lt,{name:`${e}-description`,value:f,onChange:p,className:J(`cf-question`,s?.question),children:[K(P,{className:J(`cf-title`,s?.title),children:r.detailsLabel}),K(Ft,{placeholder:r.detailsPlaceholder||`Steps to reproduce, expected vs actual behavior, etc.`,className:J(`cf-textarea`,s?.textArea),rows:4})]}),r.enableScreenshot||r.enableRecording?q(`section`,{className:J(`cf-question`,s?.question),children:[K(P,{className:J(`cf-title`,s?.title),children:`Attachments`}),q(`div`,{className:J(`cf-bug-report-actions`,s?.actions),children:[r.enableScreenshot&&q(`div`,{className:J(`cf-bug-report-screenshot-section`,s?.screenshotSection),children:[m?q(`div`,{className:J(`cf-bug-report-media-preview`,s?.mediaPreview),children:[K(`img`,{src:m,alt:`Screenshot preview`,className:J(`cf-bug-report-screenshot-img`,s?.screenshotImg)}),K(`div`,{className:J(`cf-bug-report-media-actions`,s?.mediaActions),children:K(j,{className:J(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:v,"aria-label":`Remove screenshot`,children:K(Yt,{})})})]}):K(j,{className:J(`cf-bug-report-button`,s?.button),onPress:_,isDisabled:h,children:h?`Capturing...`:`Screenshot`}),g&&K(`div`,{className:J(`cf-error`,s?.error),children:g})]}),r.enableRecording&&q(`div`,{className:J(`cf-bug-report-recording-section`,s?.recordingSection),children:[D.length>0?q(`div`,{className:J(`cf-bug-report-media-preview`,s?.mediaPreview),children:[K(be,{fallback:K(`span`,{className:J(`cf-bug-report-player-loading`,s?.playerLoading),"aria-label":`Loading recording preview...`}),children:K(Qt,{events:D})}),K(`div`,{className:J(`cf-bug-report-media-actions`,s?.mediaActions),children:K(j,{className:J(`cf-bug-report-button`,`cf-bug-report-button-action`,s?.button,s?.buttonAction),onPress:T,"aria-label":`Remove recording`,children:K(Yt,{})})})]}):K(j,{className:J(`cf-bug-report-button`,s?.button),onPress:C,children:`Record`}),x&&K(`div`,{className:J(`cf-error`,s?.error),children:x})]})]})]}):null,K(mt,{className:J(`cf-error`,s?.error),children:o})]})})},en=({id:e,title:t,description:n,properties:r,onChange:i,classNames:a,required:o,error:s})=>{let[c,l]=W(``);return V(()=>{i(c)},[i,c]),q(Lt,{isRequired:o,isInvalid:!!s,name:e,className:J(`cf-question`,a?.question),value:c,onChange:e=>{l(e),i(e)},children:[q(`div`,{className:J(`cf-header`,a?.header),children:[q(P,{className:J(`cf-title`,a?.title),children:[t,!o&&q(`span`,{className:J(`cf-label-optional`,a?.optionalLabel),children:[` `,`(optional)`]})]}),n&&K(Q,{slot:`description`,className:J(`cf-description`,a?.description),children:n})]}),K(Ft,{className:J(`cf-textarea`,a?.textarea),maxLength:r.max,rows:4,placeholder:r.placeholder||`Start typing...`}),K(mt,{className:J(`cf-error`,a?.error),children:s})]})},tn=({children:e,classNames:t,description:n,...r})=>K(bt,{...r,children:({isIndeterminate:r})=>q(G,{children:[q(`div`,{className:J(`cf-choice-label`,t?.label),children:[K(`div`,{className:J(`cf-checkbox-indicator`,t?.indicator),children:K(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:J(`cf-checkbox-indicator-svg`,t?.svg),children:r?K(`rect`,{x:1,y:7.5,width:16,height:3}):K(`polyline`,{points:`2 9 7 14 16 4`})},r?`indeterminate`:`check`)}),e]}),n&&K(`span`,{className:J(`cf-choice-description`,t?.choiceDescription),children:n})]})}),nn=({children:e,classNames:t,...n})=>K(bt,{...n,children:K(`div`,{className:J(`cf-tag-label`,t?.tagLabel),children:e})}),rn=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s})=>{let c=!!n.editable,l=n.display??`checkbox`,[u,d]=W([]),[f,p]=W(``),m=U(null),h=U(null),g=H(()=>{let e=u.indexOf(O);if(e===-1)return u;let t=[...u];return t[e]=f||O,t},[f,u]),_=l===`tag`;return V(()=>{i(g)},[i,g]),K(yt,{isRequired:o,isInvalid:!!s,name:a,value:u,onChange:d,className:J(`cf-question`,r?.question),children:({state:i})=>q(G,{children:[q(`div`,{className:J(`cf-header`,r?.header),children:[q(P,{className:J(`cf-title`,r?.title),children:[e,!o&&q(`span`,{className:J(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&K(Q,{slot:`description`,className:J(`cf-description`,r?.description),children:t})]}),q(`div`,{className:J(`cf-response-choices`,l===`tag`&&`cf-response-choices-tag`,r?.group),children:[n.options.map((e,t)=>K(_?nn:tn,{className:J(`cf-choice`,_&&[`cf-tag`,r?.tag],!_&&[`cf-checkbox`,r?.checkbox]),description:e.description,value:e.value,classNames:{tag:r?.tag,tagLabel:r?.tagLabel,choiceDescription:r?.choiceDescription,label:r?.label,indicator:r?.indicator,svg:r?.svg},children:e.value},t)),c&&(_?q(G,{children:[K(nn,{inputRef:m,onChange:e=>{h.current&&e&&requestAnimationFrame(()=>{h.current&&h.current.focus()})},className:J(`cf-choice cf-tag`,r?.tag),value:O,children:n.editable?.label}),K(wt,{"data-visible":i.value.includes(O)||void 0,value:f,onChange:e=>{p(e.target.value)},ref:h,className:J(`cf-input cf-tag-input`,r?.othersInput)})]}):q(`div`,{className:J(`cf-choice cf-others-choice`,r?.othersChoice),children:[K(tn,{inputRef:m,onChange:e=>{h.current&&e&&requestAnimationFrame(()=>{h.current&&h.current.focus()})},className:J(`cf-checkbox`,r?.checkbox),value:O,classNames:{indicator:r?.indicator,svg:r?.svg},description:n.editable?.description,children:n.editable?.label}),K(wt,{value:f,onChange:e=>{p(e.target.value)},tabIndex:i.value.includes(O)?0:-1,ref:h,onFocus:()=>{m.current?.checked===!1&&m.current.click()},className:J(`cf-input`,r?.othersInput)})]}))]}),K(mt,{className:J(`cf-error`,r?.error),children:s})]})})},an=e=>q(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[K(`circle`,{cx:12,cy:12,r:10}),K(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M7.5 8 10 9M14 9l2.5-1M9 10h.01M15 10h.01`})]}),on=e=>q(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[K(`circle`,{cx:12,cy:12,r:10}),K(`path`,{d:`M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12ZM9 9h.01M15 9h.01`})]}),sn=e=>q(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[K(`circle`,{cx:12,cy:12,r:10}),K(`path`,{d:`M16 16s-1.5-2-4-2-4 2-4 2M9 9h.01M15 9h.01`})]}),cn=e=>q(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[K(`circle`,{cx:12,cy:12,r:10}),K(`path`,{d:`M8 15h8M9 9h.01M15 9h.01`})]}),ln=e=>q(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,...e,children:[K(`circle`,{cx:12,cy:12,r:10}),K(`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2M9 9h.01M15 9h.01`})]}),un=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,width:40,height:40,fill:`none`,...e,children:K(`path`,{fill:`currentColor`,d:`m6.516 14.323-1.49 6.452a.998.998 0 0 0 1.529 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4 4.536-4.082a1 1 0 0 0-.59-1.74l-5.701-.454-2.467-5.461a.998.998 0 0 0-1.822 0L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.214 4.107zm2.853-4.326a.998.998 0 0 0 .832-.586L12 5.43l1.799 3.981a.998.998 0 0 0 .832.586l3.972.315-3.271 2.944c-.284.256-.397.65-.293 1.018l1.253 4.385-3.736-2.491a.995.995 0 0 0-1.109 0l-3.904 2.603 1.05-4.546a1 1 0 0 0-.276-.94l-3.038-2.962 4.09-.326z`})}),dn=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:40,height:40,viewBox:`0 0 24 24`,...e,children:K(`path`,{fill:`currentColor`,d:`M21.947 9.179a1.001 1.001 0 0 0-.868-.676l-5.701-.453-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4 4.536-4.082c.297-.268.406-.686.278-1.065z`})}),fn=({state:e,properties:t,classNames:n})=>{let r=e.selectedValue?Number(e.selectedValue):null;return K(`div`,{className:J(`cf-rating-display-star`,n?.ratingDisplayStar),children:Array.from({length:t.scale},(e,t)=>{let i=t+1,a=String(i),o=r&&i<=r;return K(Mt,{className:J(`cf-rating-star`,n?.ratingStar),value:a,"data-filled":o?`true`:void 0,children:K(o?dn:un,{})},t)})})},pn=({properties:e,classNames:t})=>K(`div`,{className:J(`cf-rating-display-number`,t?.ratingDisplayNumber),children:Array.from({length:e.scale},(e,n)=>{let r=n+1,i=String(r);return K(Mt,{className:J(`cf-rating-number`,t?.ratingNumber),value:i,children:r},n)})}),mn=({properties:e,classNames:t,state:n})=>{let r=H(()=>[an,sn,cn,ln,on],[]),i=H(()=>[sn,cn,ln],[]);return H(()=>e.scale===3||e.scale===5,[e.scale])?K(`div`,{className:J(`cf-rating-display-emoji`,t?.ratingDisplayEmoji),children:Array.from({length:e.scale},(n,a)=>{let o=a+1,s=String(o),c=e.scale===5?r[a]:i[a];return K(Mt,{className:J(`cf-rating-emoji`,t?.ratingEmoji),value:s,children:c&&K(c,{})},a)})}):K(pn,{properties:e,classNames:t,state:n})},hn=e=>{switch(e.properties.display??`star`){case`emoji`:return K(mn,{...e});case`number`:return K(pn,{...e});case`star`:return K(fn,{...e})}},gn=({properties:e,title:t,description:n,classNames:r,onChange:i,id:a,error:o,required:s})=>{let[c,l]=W(null),u=H(()=>c?Number(c):void 0,[c]);return V(()=>{i(u)},[i,u]),K(jt,{isRequired:s,isInvalid:!!o,name:a,className:J(`cf-question`,r?.question),value:c,onChange:l,children:({state:i})=>q(G,{children:[q(`div`,{className:J(`cf-header`,r?.header),children:[q(P,{className:J(`cf-title`,r?.title),children:[t,!s&&q(`span`,{className:J(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),n&&K(Q,{slot:`description`,className:J(`cf-description`,r?.description),children:n})]}),q(`div`,{className:J(`cf-rating-section`,r?.ratingSection),children:[K(hn,{state:i,properties:e,classNames:r}),q(`div`,{className:J(`cf-rating-text`,r?.ratingText),children:[K(`span`,{className:J(`cf-rating-text-lower`,r?.ratingTextLower),children:e.labels?.lower}),K(`span`,{className:J(`cf-rating-text-upper`,r?.ratingTextUpper),children:e.labels?.upper})]})]}),K(mt,{className:J(`cf-error`,r?.error),children:o})]})})},_n=({classNames:e,className:t,description:n,...r})=>K(Mt,{...r,className:J(t,e?.radio),children:s(r.children,t=>q(G,{children:[q(`div`,{className:J(`cf-choice-label`,e?.label),children:[K(`div`,{className:J(`cf-radio-indicator`,e?.indicator)}),t]}),n&&K(`span`,{className:J(`cf-choice-description`,e?.choiceDescription),children:n})]}))}),vn=({title:e,description:t,properties:n,classNames:r,onChange:i,id:a,required:o,error:s})=>{let[c,l]=W(null),[u,d]=W(``),f=!!n.editable,p=U(null),m=U(null),h=H(()=>c===k?u||k:c??void 0,[u,c]);return V(()=>{i(h)},[i,h]),K(jt,{isRequired:o,isInvalid:!!s,name:a,onChange:e=>{l(e),e===k&&requestAnimationFrame(()=>{m.current&&m.current.focus()})},value:c,className:J(`cf-question`,r?.question),children:({state:i})=>q(G,{children:[q(`div`,{className:J(`cf-header`,r?.header),children:[q(P,{className:J(`cf-title`,r?.title),children:[e,!o&&q(`span`,{className:J(`cf-label-optional`,r?.optionalLabel),children:[` `,`(optional)`]})]}),t&&K(Q,{slot:`description`,className:J(`cf-description`,r?.description),children:t})]}),q(`div`,{className:J(`cf-response-choices`,r?.group),children:[n.options.map((e,t)=>K(_n,{classNames:{indicator:r?.indicator,radio:J(`cf-choice cf-radio`,r?.radio)},value:e.value,description:e.description,children:e.value},t)),f&&q(`div`,{className:J(`cf-choice cf-others-choice`,r?.othersChoice),children:[K(_n,{inputRef:p,value:k,classNames:{indicator:r?.indicator,radio:J(`cf-radio`,r?.radio)},description:n.editable?.description,children:n.editable?.label}),K(wt,{tabIndex:i.selectedValue===k?0:-1,ref:m,value:u,onChange:e=>d(e.target.value),onFocus:()=>{p.current?.checked===!1&&p.current.click()},className:J(`cf-input`,r?.othersInput)})]})]}),K(mt,{className:J(`cf-error`,r?.error),children:s})]})})},yn=({properties:e,title:t,description:n,classNames:r})=>K(`div`,{className:J(`cf-question`,r?.question),children:q(`div`,{className:J(`cf-header`,r?.header),children:[t&&K(`div`,{className:J(`cf-title`,r?.title),children:t}),n&&K(`div`,{className:J(`cf-description`,r?.description),children:n})]})}),$=({question:e,onChange:t,error:n,maskAllInputs:r})=>{switch(e.properties.type){case`rating`:return K(gn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`open-ended`:return K(en,{...e,properties:e.properties,onChange:t,error:n},e.id);case`single-select`:return K(vn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`multi-select`:return K(rn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`statement`:return K(yn,{...e,properties:e.properties,onChange:t,error:n},e.id);case`bug-report`:return K($t,{...e,properties:e.properties,onChange:t,error:n,maskAllInputs:r},e.id)}return K(`div`,{children:`Unsupported question type`},e.id)},bn=({onPress:e,isDisabled:t,children:n=`Submit`})=>oe()?null:K(j,{isDisabled:t,className:`cf-submit-button`,onPress:e,children:n}),xn=e=>{switch(e){case`multi-select`:return[];case`bug-report`:return{title:``};case`statement`:return;default:return``}},Sn=e=>e!==void 0&&e!==``&&!(Array.isArray(e)&&e.length===0),Cn=({onSubmit:t,children:n,question:r,isLastQuestion:i})=>{let[a,o]=W(xn(r.properties.type)),s=H(()=>Oe(r.properties,{required:r.required}),[r.properties,r.required]),c=H(()=>{let e=s.safeParse(a);if(!e.success)return De(e.error)},[a,s]),l=H(()=>{let t=r.routingLogic;if(t.type!==`always`&&!Sn(a)&&r.required)return!0;let n=t.type===`always`?t.target:t.cases.find(t=>e({answer:a,condition:t}))?.target??t.default;return n.type===`end`?!1:n.type===`next`?!i:!0},[a,i,r.required,r.routingLogic]),u=H(()=>r.properties.buttonLabel?r.properties.buttonLabel:l?!r.required&&!Sn(a)?`Skip`:`Next`:`Submit`,[a,l,r.properties.buttonLabel,r.required]),d=B(()=>{switch(r.properties.type){case`statement`:if(r.properties.buttonUrl&&typeof window<`u`){let e=x.safeParse(r.properties.buttonUrl).data;e&&window.open(e,`_blank`)}return t(void 0);default:return t(a)}},[a,t,r.properties]),f=H(()=>{switch(r.properties.type){case`rating`:case`single-select`:return!!r.properties.shouldAutoProgress;default:return!1}},[r.properties]);return q(G,{children:[n({onChange:B(e=>{o(e),f&&Sn(e)&&s.safeParse(e).success&&t(e)},[f,s,t]),question:r,error:c}),(!f||!r.required)&&K(bn,{isDisabled:!!c,onPress:d,children:u})]})},wn=({isCompleted:e,onSubmit:t,children:n})=>q(G,{children:[n,e&&K(bn,{onPress:t})]}),Tn=e=>K(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 44 38`,...e,children:q(`g`,{transform:`translate(-2 -2) scale(1.1)`,children:[K(`path`,{d:`M16.8395 3.2139C8.2208 3.9522 1.8331 11.5311 2.5721 20.1416C3.3111 28.7523 10.897 35.134 19.5157 34.3956L27.1631 33.7406C28.9787 33.585 30.6949 33.1248 32.2669 32.4163L38.7663 35.4396C39.3254 35.6994 39.9048 35.1205 39.6447 34.562L37.0707 29.0396C40.1147 25.8995 41.8336 21.5102 41.4304 16.8128C40.6913 8.2022 33.1054 1.8205 24.4867 2.5588L16.8395 3.2139Z`,fill:`#BAE6FD`}),K(`path`,{d:`M19.6764 24.0307C19.6764 24.0307 20.9773 25.4496 23.5438 25.1228C26.1103 24.7959 27.3642 23.0095 27.3642 23.0095`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`}),K(`path`,{d:`M18.0861 16.4082C18.0861 16.4082 17.1255 18.619 14.8183 18.9139C12.5111 19.2088 11.1697 17.237 11.1697 17.237`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`}),K(`path`,{d:`M32.6296 15.0398C32.6296 15.0398 31.6691 17.2506 29.3619 17.5455C27.0548 17.8404 25.7132 15.8686 25.7132 15.8686`,stroke:`#382F40`,strokeWidth:2.4821,strokeLinecap:`round`})]})}),En=({onClick:e,isWidgetOpen:t,classNames:n,label:r=`Help us improve`})=>t?null:q(j,{onPress:e,className:J(`confetti-trigger`,n?.trigger),children:[K(`span`,{className:J(`confetti-trigger-icon-wrapper`,n?.iconWrapper),"aria-hidden":!0,children:K(Tn,{className:J(`confetti-trigger-icon`,n?.icon),width:24})}),K(`span`,{className:J(`confetti-trigger-label`,n?.label),children:r})]}),Dn=({trigger:e,children:t,publishableKey:n,surveyId:r})=>{let i=f(),[a,s]=W(!1),[c,l]=W(!1);if(!i.isVisible)return null;let u=()=>{s(!1)};return q(G,{children:[e({onClick:()=>s(!0),isWidgetOpen:a,hasSubmitted:c}),a&&K(o.Provider,{value:{...i,dismiss:()=>{i.dismiss(),u()},submit:async e=>{let t=await i.submit(e);return l(!0),t}},children:t({onDismiss:u,surveyId:r,publishableKey:n})})]})},On=({trigger:e=e=>K(En,{...e}),children:t,...n})=>K(ye,{fallback:K(G,{}),children:K(E,{...n,alwaysRenderChildren:!0,children:K(Dn,{trigger:e,surveyId:n.surveyId,publishableKey:n.publishableKey,children:t})})}),kn=e=>K(ye,{fallback:K(G,{}),children:K(T,{type:`embedded`,children:K(Pe,{...e,shouldAutoSubmit:!1,children:({questions:t,update:n,isCompleted:r,submit:i,isSubmitted:a,errors:o})=>a?K(Rt,{}):K(wn,{onSubmit:i,isCompleted:r,children:t.filter(({visible:e})=>!!e).map(t=>K($,{question:t,error:o[t.id]||``,maskAllInputs:e.options?.bugReport?.maskAllInputs,onChange:e=>n({question:t.position,answer:e})},t.position))})})})}),An=({onDismiss:e,closeOnFinishMs:t,isDismissable:n,...r})=>K(ye,{fallback:K(G,{}),children:K(T,{type:`modal`,children:K(E,{...r,children:K(me,{onDismiss:e,closeOnFinishMs:t,isDismissable:n,children:({setIsFinished:e})=>K(Ne,{...r,shouldAutoSubmit:!1,onFinished:()=>{e(),r.onFinished?.()},children:({questions:e,update:t,isCompleted:n,errors:i,submit:a,isSubmitted:o})=>o?K(Rt,{}):K(wn,{onSubmit:a,isCompleted:n,children:e.filter(({visible:e})=>!!e).map(e=>K($,{question:e,error:i[e.id]||``,maskAllInputs:r.options?.bugReport?.maskAllInputs,onChange:n=>t({question:e.position,answer:n})},e.position))})})})})})}),jn=({onDismiss:e,closeOnFinishMs:t,...n})=>K(ye,{fallback:K(G,{}),children:K(T,{type:`popover`,children:K(E,{...n,children:K(zt,{onDismiss:e,closeOnFinishMs:t,children:({setIsFinished:e})=>K(Ne,{shouldAutoSubmit:!0,...n,onFinished:()=>{e(),n.onFinished?.()},children:({current:e,questions:t,update:r,isSubmitted:i})=>{let a=e===t.length-1;if(i)return K(Rt,{});let o=t[e];return o?K(Cn,{isLastQuestion:a,question:o,onSubmit:t=>r({question:e,answer:t}),children:e=>K($,{maskAllInputs:n.options?.bugReport?.maskAllInputs,...e})}):K(G,{})}})})})})}),Mn=e=>K(Pe,{...e,shouldAutoSubmit:!0,children:({current:t,questions:n,update:r,isSubmitted:i})=>{let a=t===n.length-1;if(i)return K(Rt,{});let o=n[t];return o?K(Cn,{isLastQuestion:a,question:o,onSubmit:e=>r({question:t,answer:e}),children:t=>K($,{maskAllInputs:e.options?.bugReport?.maskAllInputs,...t})}):K(G,{})}}),Nn=({delay:e})=>{let[t,n]=W(!1),r=H(()=>e,[]);return V(()=>{let e=setTimeout(()=>{n(!0)},r);return()=>clearTimeout(e)},[]),{isVisible:t}},Pn=({visits:e,respondent:t})=>{let[n,r]=Ce(`cfti:${H(()=>window.location.pathname,[])}:visits:${t??``}`,0);return V(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:B(()=>r(0),[r])}},Fn=({visits:e,respondent:t})=>{let[n,r]=we(`cfti:${H(()=>window.location.pathname,[])}:visits:${t??``}`,0);return V(()=>{r(e=>e+1)},[r]),{isVisible:n>=e,reset:B(()=>r(0),[r])}},In=({threshold:e})=>{let[t,n]=W(()=>typeof window>`u`?!1:window.scrollY>=e);return V(()=>{let t=()=>{window.scrollY>=e&&n(!0)};return window.addEventListener(`scroll`,t,{passive:!0}),()=>window.removeEventListener(`scroll`,t)},[e]),{isVisible:t}};export{pe as CloseButton,Pe as Confetti,o as ConfettiContext,Ne as ConfettiController,E as ConfettiProvider,On as ConfettiTrigger,Tn as ConfettiTriggerIcon,En as DefaultConfettiTrigger,wn as Embed,kn as EmbeddedConfetti,Cn as Flow,en as FreeText,An as ModalConfetti,me as ModalContainer,rn as MultiChoice,jn as PopoverConfetti,zt as PopoverContainer,gn as Rating,vn as SingleChoice,yn as Statement,Mn as StepperConfetti,$ as SurveyQuestionFactory,Rt as ThankYouMessage,f as useConfetti,Nn as useVisibleAfterDelay,Pn as useVisibleAfterPageVisits,In as useVisibleAfterScroll,Fn as useVisibleAfterSessionPageVisits};
@@ -1 +1 @@
1
- import{z as e}from"zod/mini";const t=({index:e,questions:t,answers:i})=>{if(e===0)return!0;for(let a=0;a<e;a++){let o=t[a],s=o?i[o.id]:void 0;if(!o||!o.visible)continue;let c=o.routingLogic;if(c.type===`always`){if(n({position:a,value:c.target})===e)return!0;continue}if(s==null&&o.required)continue;let l=c.cases,u=s===null?void 0:l.find(e=>r({answer:s,condition:e}));if(!u){if(n({position:a,value:c.default})===e)return!0;continue}if(n({position:a,value:u.target})===e)return!0}return!1},n=({position:e,value:t})=>{switch(t.type){case`next`:return e+1;case`jump`:return t.target;case`end`:return null}},r=({answer:e,condition:t})=>{let n=i(t.value);switch(t.operator){case`equal`:return e===n;case`not-equal`:return e!==n;case`greater`:return typeof e==`number`&&typeof n==`number`&&e>n;case`greater-or-equal`:return typeof e==`number`&&typeof n==`number`&&e>=n;case`less`:return typeof e==`number`&&typeof n==`number`&&e<n;case`less-or-equal`:return typeof e==`number`&&typeof n==`number`&&e<=n;case`contains`:return Array.isArray(e)&&typeof n==`string`&&e.includes(n);case`not-contains`:return Array.isArray(e)&&typeof n==`string`&&!e.includes(n)}},i=e=>e.value,a=`__confetti_bug_report_recording_event`,o=e.object({detail:e.object({isRecording:e.boolean()})});export{t as i,o as n,r,a as t};
1
+ import{z as e}from"zod/mini";const t=({index:e,questions:t,answers:i})=>{if(e===0)return!0;for(let a=0;a<e;a++){let o=t[a],s=o?i[o.id]:void 0;if(!o||!o.visible)continue;let c=o.routingLogic;if(c.type===`always`){if(n({position:a,value:c.target})===e)return!0;continue}if(s==null&&o.required)continue;let l=c.cases,u=s===null?void 0:l.find(e=>r({answer:s,condition:e}));if(!u){if(n({position:a,value:c.default})===e)return!0;continue}if(n({position:a,value:u.target})===e)return!0}return!1},n=({position:e,value:t})=>{switch(t.type){case`next`:return e+1;case`jump`:return t.target;case`end`:return null}},r=({answer:e,condition:t})=>{let n=i(t.value);switch(t.operator){case`equal`:return e===n;case`not-equal`:return e!==n;case`greater`:return typeof e==`number`&&typeof n==`number`&&e>n;case`greater-or-equal`:return typeof e==`number`&&typeof n==`number`&&e>=n;case`less`:return typeof e==`number`&&typeof n==`number`&&e<n;case`less-or-equal`:return typeof e==`number`&&typeof n==`number`&&e<=n;case`contains`:return Array.isArray(e)&&typeof n==`string`&&e.includes(n);case`not-contains`:return Array.isArray(e)&&typeof n==`string`&&!e.includes(n)}},i=e=>e.value,a=`cfti-mask`,o=`cfti-block`,s=`__confetti_bug_report_recording_event`,c=e.object({detail:e.object({isRecording:e.boolean()})});export{r as a,c as i,a as n,t as o,s as r,o as t};
@@ -1,4 +1,4 @@
1
- import { t as Answer, u as BinaryOperatorCondition } from "./types-BUY-8MBx.js";
1
+ import { t as Answer, u as BinaryOperatorCondition } from "./types-JeyKtT3p.js";
2
2
  import { z } from "zod/mini";
3
3
 
4
4
  //#region src/core/logic/routing.d.ts
@@ -12,6 +12,8 @@ declare const evaluateCondition: ({
12
12
  }) => boolean;
13
13
  //#endregion
14
14
  //#region src/internals.d.ts
15
+ declare const BUG_REPORT_MASK_CLASS = "cfti-mask";
16
+ declare const BUG_REPORT_BLOCK_CLASS = "cfti-block";
15
17
  declare const __INTERNAL_BUG_REPORT_RECORDING_EVENT = "__confetti_bug_report_recording_event";
16
18
  declare const internalBugReportRecordingEventSchema: z.ZodMiniObject<{
17
19
  detail: z.ZodMiniObject<{
@@ -19,4 +21,4 @@ declare const internalBugReportRecordingEventSchema: z.ZodMiniObject<{
19
21
  }, z.core.$strip>;
20
22
  }, z.core.$strip>;
21
23
  //#endregion
22
- export { __INTERNAL_BUG_REPORT_RECORDING_EVENT, internalBugReportRecordingEventSchema, evaluateCondition as unstableInternalConfettiEvaluateCondition };
24
+ export { BUG_REPORT_BLOCK_CLASS, BUG_REPORT_MASK_CLASS, __INTERNAL_BUG_REPORT_RECORDING_EVENT, internalBugReportRecordingEventSchema, evaluateCondition as unstableInternalConfettiEvaluateCondition };
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./internals-pYkbsaWU.js";export{n as __INTERNAL_BUG_REPORT_RECORDING_EVENT,e as internalBugReportRecordingEventSchema,t as unstableInternalConfettiEvaluateCondition};
1
+ import{a as e,i as t,n,r,t as i}from"./internals-Dzl6abGJ.js";export{i as BUG_REPORT_BLOCK_CLASS,n as BUG_REPORT_MASK_CLASS,r as __INTERNAL_BUG_REPORT_RECORDING_EVENT,t as internalBugReportRecordingEventSchema,e as unstableInternalConfettiEvaluateCondition};
@@ -0,0 +1,8 @@
1
+ var e=Object.defineProperty,t=(e,t)=>()=>(e&&(t=e(e=0)),t),n=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})};function r(e){if(e===!0)return`soft`;if(e===!1)return`disabled`;if(typeof e==`string`){let t=e.toLowerCase().trim();if(t===`auto`)return`auto`;if(t===`full`)return`full`;if(t===`soft`||t===`disabled`)return t}return`soft`}function i(e=`soft`){switch(o.session.__counterEpoch=(o.session.__counterEpoch||0)+1,e){case`auto`:o.session.styleMap=new Map,o.session.nodeMap=new Map;return;case`soft`:o.session.styleMap=new Map,o.session.nodeMap=new Map,o.session.styleCache=new WeakMap;return;case`full`:return;case`disabled`:o.session.styleMap=new Map,o.session.nodeMap=new Map,o.session.styleCache=new WeakMap,o.computedStyle=new WeakMap,o.baseStyle=new a(50),o.defaultStyle=new a(30),o.image=new a(100),o.background=new a(100),o.resource=new a(150),o.font=new Set;return;default:o.session.styleMap=new Map,o.session.nodeMap=new Map,o.session.styleCache=new WeakMap;return}}var a,o,s=t(()=>{a=class extends Map{constructor(e=100,...t){super(...t),this._maxSize=e}set(e,t){if(this.size>=this._maxSize&&!this.has(e)){let e=this.keys().next().value;e!==void 0&&this.delete(e)}return super.set(e,t)}},o={image:new a(100),background:new a(100),resource:new a(150),defaultStyle:new a(30),baseStyle:new a(50),computedStyle:new WeakMap,measureHints:new WeakMap,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}}});function c(e){let t=e.match(/url\((['"]?)(.*?)(\1)\)/);if(!t)return null;let n=t[2].trim();return n.startsWith(`#`)?null:n}function l(e){if(!e||e===`none`)return``;let t=e.replace(/translate[XY]?\([^)]*\)/g,``);return t=t.replace(/matrix\(([^)]+)\)/g,(e,t)=>{let n=t.split(`,`).map(e=>e.trim());return n.length===6?(n[4]=`0`,n[5]=`0`,`matrix(${n.join(`, `)})`):`matrix(${t})`}),t=t.replace(/matrix3d\(([^)]+)\)/g,(e,t)=>{let n=t.split(`,`).map(e=>e.trim());return n.length===16?(n[12]=`0`,n[13]=`0`,`matrix3d(${n.join(`, `)})`):`matrix3d(${t})`}),t.trim().replace(/\s{2,}/g,` `)}function u(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function d(e,t){if(!e||/^(data|blob|about|#)/i.test(e.trim()))return e;try{let n=t||typeof document<`u`&&(document.baseURI||document.location?.href)||`http://localhost/`;return new URL(e,n).href}catch{return e}}var f=t(()=>{});function p(e=`[snapDOM]`,{ttlMs:t=5*6e4,maxEntries:n=12}={}){let r=new Map,i=0;function a(a,o,s){if(i>=n)return;let c=Date.now();(r.get(o)||0)>c||(r.set(o,c+t),i++,a===`warn`&&console&&console.warn?console.warn(`${e} ${s}`):console&&console.error&&console.error(`${e} ${s}`))}return{warnOnce(e,t){a(`warn`,e,t)},errorOnce(e,t){a(`error`,e,t)},reset(){r.clear(),i=0}}}function m(e){return/^data:|^blob:|^about:blank$/i.test(e)}function h(e,t){try{let n=typeof location<`u`&&location.href?location.href:`http://localhost/`,r=t.includes(`{url}`)?t.split(`{url}`)[0]:t,i=new URL(r||`.`,n),a=new URL(e,n);if(a.origin===i.origin)return!0;let o=a.searchParams;if(o&&(o.has(`url`)||o.has(`target`)))return!0}catch{}return!1}function g(e,t){if(!t||m(e)||h(e,t))return!1;try{let t=typeof location<`u`&&location.href?location.href:`http://localhost/`,n=new URL(e,t);return typeof location<`u`?n.origin!==location.origin:!0}catch{return!!t}}function _(e,t){return t?t.includes(`{url}`)?t.replace(`{urlRaw}`,u(e)).replace(`{url}`,encodeURIComponent(e)):/[?&]url=?$/.test(t)?`${t}${encodeURIComponent(e)}`:t.endsWith(`?`)?`${t}url=${encodeURIComponent(e)}`:t.endsWith(`/`)?`${t}${u(e)}`:`${t}${t.includes(`?`)?`&`:`?`}url=${encodeURIComponent(e)}`:e}function v(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(Error(`read_failed`)),r.readAsDataURL(e)})}function y(e,t){return[t.as||`blob`,t.timeout??3e3,t.useProxy||``,t.errorTTL??8e3,e].join(`|`)}async function b(e,t={}){let n=t.as??`blob`,r=t.timeout??3e3,i=t.useProxy||``,a=t.errorTTL??8e3,o=t.headers||{},s=!!t.silent;if(/^data:/i.test(e))try{if(n===`text`)return{ok:!0,data:String(e),status:200,url:e,fromCache:!1};if(n===`dataURL`)return{ok:!0,data:String(e),status:200,url:e,fromCache:!1,mime:String(e).slice(5).split(`;`)[0]||``};let[,t=``,r=``]=String(e).match(/^data:([^,]*),(.*)$/)||[],i=/;base64/i.test(t)?atob(r):decodeURIComponent(r),a=new Uint8Array([...i].map(e=>e.charCodeAt(0))),o=new Blob([a],{type:(t||``).split(`;`)[0]||``});return{ok:!0,data:o,status:200,url:e,fromCache:!1,mime:o.type||``}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:`special_url_error`}}if(/^blob:/i.test(e))try{let t=await fetch(e);if(!t.ok)return{ok:!1,data:null,status:t.status,url:e,fromCache:!1,reason:`http_error`};let r=await t.blob(),i=r.type||t.headers.get(`content-type`)||``;return n===`dataURL`?{ok:!0,data:await v(r),status:t.status,url:e,fromCache:!1,mime:i}:n===`text`?{ok:!0,data:await r.text(),status:t.status,url:e,fromCache:!1,mime:i}:{ok:!0,data:r,status:t.status,url:e,fromCache:!1,mime:i}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:`network`}}if(/^about:blank$/i.test(e))return n===`dataURL`?{ok:!0,data:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==`,status:200,url:e,fromCache:!1,mime:`image/png`}:{ok:!0,data:n===`text`?``:new Blob([]),status:200,url:e,fromCache:!1};let c=y(e,{as:n,timeout:r,useProxy:i,errorTTL:a}),l=C.get(c);if(l&&l.until>Date.now())return{...l.result,fromCache:!0};l&&C.delete(c);let u=S.get(c);if(u)return u;let d=g(e,i)?_(e,i):e,f=t.credentials;if(!f)try{let t=typeof location<`u`&&location.href?location.href:`http://localhost/`,n=new URL(e,t);f=typeof location<`u`&&n.origin===location.origin?`include`:`omit`}catch{f=`omit`}let p=new AbortController,m=setTimeout(()=>p.abort(`timeout`),r),h=(async()=>{try{let r=await fetch(d,{signal:p.signal,credentials:f,headers:o});if(!r.ok){let i={ok:!1,data:null,status:r.status,url:d,fromCache:!1,reason:`http_error`};if(a>0&&C.set(c,{until:Date.now()+a,result:i}),!s){let t=`${r.status} ${r.statusText||``}`.trim();x.warnOnce(`http:${r.status}:${n}:${new URL(e,location?.href??`http://localhost/`).origin}`,`HTTP error ${t} while fetching ${n} ${e}`)}return t.onError&&t.onError(i),i}if(n===`text`)return{ok:!0,data:await r.text(),status:r.status,url:d,fromCache:!1};let i=await r.blob(),l=i.type||r.headers.get(`content-type`)||``;return n===`dataURL`?{ok:!0,data:await v(i),status:r.status,url:d,fromCache:!1,mime:l}:{ok:!0,data:i,status:r.status,url:d,fromCache:!1,mime:l}}catch(i){let o=i&&typeof i==`object`&&`name`in i&&i.name===`AbortError`?String(i.message||``).includes(`timeout`)?`timeout`:`abort`:`network`,l={ok:!1,data:null,status:0,url:d,fromCache:!1,reason:o};if(!/^blob:/i.test(e)&&a>0&&C.set(c,{until:Date.now()+a,result:l}),!s){let t=`${o}:${n}:${new URL(e,location?.href??`http://localhost/`).origin}`,i=o===`timeout`?`Timeout after ${r}ms. Consider increasing timeout or using a proxy for ${e}`:o===`abort`?`Request aborted while fetching ${n} ${e}`:`Network/CORS issue while fetching ${n} ${e}. A proxy may be required`;x.errorOnce(t,i)}return t.onError&&t.onError(l),l}finally{clearTimeout(m),S.delete(c)}})();return S.set(c,h),h}var x,S,C,w=t(()=>{f(),x=p(`[snapDOM]`,{ttlMs:3*6e4,maxEntries:10}),S=new Map,C=new Map});async function T(e,t={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\(/i.test(e)||e.trim()===`none`)return e;let n=c(e);if(!n)return e;let r=u(d(n));if(o.background.has(r)){let e=o.background.get(r);return e?`url("${e}")`:`none`}try{let e=await b(r,{as:`dataURL`,useProxy:t.useProxy});return e.ok?(o.background.set(r,e.data),`url("${e.data}")`):(o.background.set(r,null),`none`)}catch{return o.background.set(r,null),`none`}}var E=t(()=>{s(),f(),w()});function D(e){if(e=String(e).toLowerCase(),N.has(e)){let t={};return o.defaultStyle.set(e,t),t}if(o.defaultStyle.has(e))return o.defaultStyle.get(e);let t=document.getElementById(`snapdom-sandbox`);t||(t=document.createElement(`div`),t.id=`snapdom-sandbox`,t.setAttribute(`data-snapdom-sandbox`,`true`),t.setAttribute(`aria-hidden`,`true`),t.style.position=`absolute`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.style.width=`0px`,t.style.height=`0px`,t.style.overflow=`hidden`,document.body.appendChild(t));let n=document.createElement(e);n.style.all=`initial`,t.appendChild(n);let r=getComputedStyle(n),i={};for(let e of r)O(e)||(i[e]=r.getPropertyValue(e));return t.removeChild(n),o.defaultStyle.set(e,i),i}function O(e){let t=String(e).toLowerCase();return!!(ae.has(t)||F.test(t)||P.test(t))}function k(e,t){if(t=String(t||``).toLowerCase(),N.has(t))return``;let n=[],r=D(t),i=(e.display||``).toLowerCase()===`inline`||new Set([`span`,`small`,`em`,`strong`,`b`,`i`,`u`,`s`,`code`,`cite`,`mark`,`sub`,`sup`]).has(t);for(let[t,a]of Object.entries(e)){if(O(t)||i&&(t===`width`||t===`min-width`||t===`max-width`))continue;let e=r[t];a&&a!==e&&n.push(`${t}:${a}`)}return n.sort(),n.join(`;`)}function A(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),typeof e.querySelectorAll==`function`&&e.querySelectorAll(`*`).forEach(e=>t.add(e.tagName.toLowerCase())),Array.from(t))}function ee(e){let t=new Map;for(let n of e){let e=o.defaultStyle.get(n);if(!e)continue;let r=Object.entries(e).map(([e,t])=>`${e}:${t};`).sort().join(``);r&&(t.has(r)||t.set(r,[]),t.get(r).push(n))}let n=``;for(let[e,r]of t.entries())n+=`${r.join(`,`)} { ${e} }
2
+ `;return n}function j(e){let t=Array.from(new Set(e.values())).filter(Boolean).sort(),n=new Map,r=1;for(let e of t)n.set(e,`c${r++}`);return n}function te(e){try{let t=e?.ownerDocument;if(!t)return typeof window<`u`?window:null;let n=t.defaultView;if(n&&typeof n.getComputedStyle==`function`)return n;if(typeof window<`u`&&window.frames)for(let e=0;e<window.frames.length;e++)try{if(window.frames[e]?.document===t)return window.frames[e]}catch{}}catch{}return typeof window<`u`?window:null}function M(e,t=null){let n=()=>{let e={length:0,getPropertyValue:()=>``,item:()=>``};return e[Symbol.iterator]=function*(){},e};if(!(e instanceof Element)){let r=typeof window<`u`?window:null;if(r&&typeof r.getComputedStyle==`function`)try{return r.getComputedStyle(e,t)||n()}catch{return n()}return n()}let r=o.computedStyle.get(e);r||(r=new Map,o.computedStyle.set(e,r));let i=r.get(t);if(!i){let a=te(e),o=null;try{o=a&&typeof a.getComputedStyle==`function`?a.getComputedStyle(e,t):null}catch{}if(!o&&typeof window<`u`&&typeof window.getComputedStyle==`function`)try{e.ownerDocument===document&&(o=window.getComputedStyle(e,t))}catch{}i=o||n(),r.set(t,i)}return i}function ne(e){let t={};for(let n of e)t[n]=e.getPropertyValue(n);for(let e of oe){let n=t[`border-${e}-style`];(n===`none`||n===`hidden`||t[`border-${e}-width`]===`0px`)&&(delete t[`border-${e}-style`],delete t[`border-${e}-width`],delete t[`border-${e}-color`])}return t}function re(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`&&n++,a===`)`&&n--,a===`,`&&n===0&&(t.push(e.slice(r,i).trim()),r=i+1)}return t.push(e.slice(r).trim()),t}var ie,N,P,F,ae,oe,se=t(()=>{s(),ie=new Set([`meta`,`script`,`noscript`,`title`,`link`,`template`]),N=new Set([`meta`,`link`,`style`,`title`,`noscript`,`script`,`template`,`g`,`defs`,`use`,`marker`,`mask`,`clipPath`,`pattern`,`path`,`polygon`,`polyline`,`line`,`circle`,`ellipse`,`rect`,`filter`,`lineargradient`,`radialgradient`,`stop`]),P=/(?:^|-)(animation|transition)(?:-|$)/i,F=/^(--.+|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,ae=new Set([`cursor`,`pointer-events`,`touch-action`,`user-select`,`print-color-adjust`,`speak`,`reading-flow`,`reading-order`,`anchor-name`,`anchor-scope`,`container-name`,`container-type`,`timeline-scope`,`zoom`]),oe=[`top`,`right`,`bottom`,`left`]});function I(e,{fast:t=!1}={}){if(t)return e();`requestIdleCallback`in window?requestIdleCallback(e,{timeout:50}):setTimeout(e,1)}function ce(){if(typeof navigator>`u`)return!1;if(navigator.userAgentData)return navigator.userAgentData.platform===`iOS`;let e=navigator.userAgent||``,t=/iPhone|iPad|iPod/.test(e),n=navigator.maxTouchPoints>2&&/Macintosh/.test(e);return t||n}function L(){if(typeof navigator>`u`)return!1;let e=navigator.userAgent||``,t=e.toLowerCase(),n=t.includes(`safari`)&&!t.includes(`chrome`)&&!t.includes(`crios`)&&!t.includes(`fxios`)&&!t.includes(`android`),r=/applewebkit/i.test(e),i=/mobile/i.test(e),a=!/safari/i.test(e),o=r&&i&&a,s=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(e),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(t),l=/ipad|iphone|ipod/.test(t)&&r;return n||o||s||c||l}function le(){if(typeof navigator>`u`)return!1;let e=(navigator.userAgent||``).toLowerCase();return e.includes(`firefox`)||e.includes(`fxios`)}var R=t(()=>{});function z(e,t,n){let r=e&&typeof e==`object`&&(e.options||e);r&&r.debug&&(n===void 0?console.warn(`[snapdom]`,t):console.warn(`[snapdom]`,t,n))}var ue=t(()=>{}),B=t(()=>{E(),se(),R(),f(),ue()}),de={};n(de,{toCanvas:()=>xe});function fe(e){return typeof e==`string`&&/^data:image\/svg\+xml/i.test(e)}function pe(e){let t=e.indexOf(`,`);return t>=0?decodeURIComponent(e.slice(t+1)):``}function me(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function he(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`&&r++,a===`)`&&(r=Math.max(0,r-1)),a===`;`&&r===0?(t.push(n),n=``):n+=a}return n.trim()&&t.push(n),t.map(e=>e.trim()).filter(Boolean)}function ge(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`&&r++,a===`)`&&(r=Math.max(0,r-1)),a===`,`&&r===0?(t.push(n.trim()),n=``):n+=a}n.trim()&&t.push(n.trim());let i=[];for(let e of t){if(/\binset\b/i.test(e))continue;let[t=`0px`,n=`0px`,r=`0px`]=e.match(/-?\d+(?:\.\d+)?px/gi)||[],a=e.replace(/-?\d+(?:\.\d+)?px/gi,``).replace(/\binset\b/gi,``).trim().replace(/\s{2,}/g,` `),o=!!a&&a!==`,`;i.push(`drop-shadow(${t} ${n} ${r}${o?` ${a}`:``})`)}return i.join(` `)}function _e(e){let t=he(e),n=null,r=null,i=null,a=[];for(let e of t){let t=e.indexOf(`:`);if(t<0)continue;let o=e.slice(0,t).trim().toLowerCase(),s=e.slice(t+1).trim();o===`box-shadow`?i=s:o===`filter`?n=s:o===`-webkit-filter`?r=s:a.push([o,s])}if(i){let e=ge(i);e&&(n=n?`${n} ${e}`:e,r=r?`${r} ${e}`:e)}let o=[...a];return n&&o.push([`filter`,n]),r&&o.push([`-webkit-filter`,r]),o.map(([e,t])=>`${e}:${t}`).join(`;`)}function ve(e){return e.replace(/([^{}]+)\{([^}]*)\}/g,(e,t,n)=>`${t}{${_e(n)}}`)}function ye(e){return e=e.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi,(e,t)=>e.replace(t,ve(t))),e=e.replace(/style=(['"])([\s\S]*?)\1/gi,(e,t,n)=>`style=${t}${_e(n)}${t}`),e}function be(e){if(!L()||!fe(e))return e;try{return me(ye(pe(e)))}catch{return e}}async function xe(e,t){let{width:n,height:r,scale:i=1,dpr:a=1,meta:o={},backgroundColor:s}=t;e=be(e);let c=new Image;if(c.loading=`eager`,c.decoding=`sync`,c.crossOrigin=`anonymous`,c.src=e,await c.decode(),L()){c.style.cssText=`position:fixed;left:-99999px;top:-99999px;pointer-events:none`,document.body.appendChild(c);try{await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))}finally{try{c.remove()}catch{}}}let l=c.naturalWidth,u=c.naturalHeight,d=Number.isFinite(o.w0)?o.w0:l,f=Number.isFinite(o.h0)?o.h0:u,p,m,h=Number.isFinite(n),g=Number.isFinite(r);if(h&&g)p=Math.max(1,n),m=Math.max(1,r);else if(h){let e=n/Math.max(1,d);p=n,m=f*e}else if(g){let e=r/Math.max(1,f);m=r,p=d*e}else p=l,m=u;p*=i,m*=i;let _=document.createElement(`canvas`);_.width=p*a,_.height=m*a,_.style.width=`${p}px`,_.style.height=`${m}px`;let v=_.getContext(`2d`);return a!==1&&v.scale(a,a),s&&(v.save(),v.fillStyle=s,v.fillRect(0,0,p,m),v.restore()),v.drawImage(c,0,0,p,m),_}var Se=t(()=>{R()}),Ce={};n(Ce,{rasterize:()=>we});async function we(e,t){let n=await xe(e,t),r=new Image;return r.src=n.toDataURL(`image/${t.format}`,t.quality),await r.decode(),r.style.width=`${n.width/t.dpr}px`,r.style.height=`${n.height/t.dpr}px`,r}var Te=t(()=>{Se()}),Ee={};n(Ee,{toImg:()=>De,toSvg:()=>De});async function De(e,t){let{scale:n=1,width:r,height:i,meta:a={}}=t,o=Number.isFinite(r),s=Number.isFinite(i),c=Number.isFinite(n)&&n!==1||o||s;if(L()&&c)return await we(e,{...t,format:`png`,quality:1,meta:a});let l=new Image;if(l.decoding=`sync`,l.loading=`eager`,l.src=e,await l.decode(),o&&s)l.style.width=`${r}px`,l.style.height=`${i}px`;else if(o){let e=Number.isFinite(a.w0)?a.w0:l.naturalWidth,t=Number.isFinite(a.h0)?a.h0:l.naturalHeight,n=r/Math.max(1,e);l.style.width=`${r}px`,l.style.height=`${Math.round(t*n)}px`}else if(s){let e=Number.isFinite(a.w0)?a.w0:l.naturalWidth,t=Number.isFinite(a.h0)?a.h0:l.naturalHeight,n=i/Math.max(1,t);l.style.height=`${i}px`,l.style.width=`${Math.round(e*n)}px`}else{let r=Math.round(l.naturalWidth*n),i=Math.round(l.naturalHeight*n);if(l.style.width=`${r}px`,l.style.height=`${i}px`,typeof e==`string`&&e.startsWith(`data:image/svg+xml`))try{let t=decodeURIComponent(e.split(`,`)[1]).replace(/width="[^"]*"/,`width="${r}"`).replace(/height="[^"]*"/,`height="${i}"`);e=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,l.src=e}catch(e){z(t,`SVG width/height patch in toImg failed`,e)}}return l}var Oe=t(()=>{B(),Te()}),ke={};n(ke,{toBlob:()=>Ae});async function Ae(e,t){let n=t.type;if(n===`svg`){let t=decodeURIComponent(e.split(`,`)[1]);return new Blob([t],{type:`image/svg+xml`})}let r=await xe(e,t);return new Promise(e=>r.toBlob(t=>e(t),`image/${n}`,t.quality))}var je=t(()=>{Se()}),Me={};n(Me,{download:()=>Pe});async function Ne(e,t){let n=new File([e],t,{type:e.type});if(!navigator.canShare?.({files:[n]}))return!1;try{await navigator.share({files:[n],title:t})}catch(e){if(e.name!==`AbortError`)return!1}return!0}async function Pe(e,t){let n=new Set([`png`,`jpeg`,`jpg`,`webp`,`svg`]),r=(t?.type||``).toLowerCase(),i=n.has(r)?r:``,a=(t?.format||i||``).toLowerCase(),o=a===`jpg`?`jpeg`:a||`png`,s=t?.filename||`snapdom.${o}`,c={...t||{},format:o,type:o};c.dpr=1;let l=ce();if(o===`svg`){let t=await Ae(e,{...c,type:`svg`});if(l&&await Ne(t,s))return;let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=s,document.body.appendChild(r),r.click(),URL.revokeObjectURL(n),r.remove();return}let u=await xe(e,c);if(l){let e=`image/${o}`,n=await new Promise(n=>u.toBlob(n,e,t?.quality));if(n&&await Ne(n,s))return}let d=document.createElement(`a`);d.href=u.toDataURL(`image/${o}`,t?.quality),d.download=s,document.body.appendChild(d),d.click(),d.remove()}var Fe=t(()=>{je(),Se(),R()});B(),B(),s();var Ie=new WeakMap,V=new Map,Le=2e3,Re=0;function ze(){Re++,V.size>Le&&V.clear()}var Be=!1;function Ve(e=document.documentElement){if(!Be){Be=!0;try{new MutationObserver(()=>ze()).observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(()=>ze()).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let e=document.fonts;e&&(e.addEventListener?.(`loadingdone`,ze),e.ready?.then(()=>ze()).catch(()=>{}))}catch{}}}function He(e,t={}){let n={},r=e.getPropertyValue(`visibility`),i=t.excludeStyleProps;for(let t=0;t<e.length;t++){let r=e[t];if(O(r)||i&&(i instanceof RegExp&&i.test(r)||typeof i==`function`&&i(r)))continue;let a=e.getPropertyValue(r);(r===`background-image`||r===`content`)&&a.includes(`url(`)&&!a.includes(`data:`)&&(a=`none`),n[r]=a}for(let t of[`text-decoration-line`,`text-decoration-color`,`text-decoration-style`,`text-decoration-thickness`,`text-underline-offset`,`text-decoration-skip-ink`])if(!n[t])try{let r=e.getPropertyValue(t);r&&(n[t]=r)}catch{}for(let t of[`-webkit-text-stroke`,`-webkit-text-stroke-width`,`-webkit-text-stroke-color`,`paint-order`])if(!n[t])try{let r=e.getPropertyValue(t);r&&(n[t]=r)}catch{}if(t.embedFonts){for(let t of[`font-feature-settings`,`font-variation-settings`,`font-kerning`,`font-variant`,`font-variant-ligatures`,`font-optical-sizing`])if(!n[t])try{let r=e.getPropertyValue(t);r&&(n[t]=r)}catch{}}r===`hidden`&&(n.opacity=`0`);try{(n[`content-visibility`]||e.getPropertyValue(`content-visibility`))===`hidden`&&(n.visibility=`hidden`)}catch{}let a=parseFloat(e.getPropertyValue(`border-top-width`)||0)||0,o=parseFloat(e.getPropertyValue(`border-right-width`)||0)||0,s=parseFloat(e.getPropertyValue(`border-bottom-width`)||0)||0,c=parseFloat(e.getPropertyValue(`border-left-width`)||0)||0;if(a===0&&o===0&&s===0&&c===0){let t=(e.getPropertyValue(`border-image-source`)||``).trim(),r=t&&t!==`none`;for(let e of`border.border-top.border-right.border-bottom.border-left.border-width.border-style.border-color.border-top-width.border-top-style.border-top-color.border-right-width.border-right-style.border-right-color.border-bottom-width.border-bottom-style.border-bottom-color.border-left-width.border-left-style.border-left-color.border-block.border-block-width.border-block-style.border-block-color.border-inline.border-inline-width.border-inline-style.border-inline-color`.split(`.`))delete n[e];r||(n.border=`none`)}return n}var Ue=new WeakMap;function We(e){let t=Ue.get(e);return t||(t=Object.entries(e).sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0).map(([e,t])=>`${e}:${t}`).join(`;`),Ue.set(e,t),t)}function Ge(e,t=null,n={}){let r=Ie.get(e);if(r&&r.epoch===Re)return r.snapshot;let i=t||getComputedStyle(e),a=He(i,n);return Qe(e,i,a),Ie.set(e,{epoch:Re,snapshot:a}),a}function Ke(e,t){return e&&e.session&&e.persist?e:e&&(e.styleMap||e.styleCache||e.nodeMap)?{session:e,persist:{snapshotKeyCache:V,defaultStyle:o.defaultStyle,baseStyle:o.baseStyle,image:o.image,resource:o.resource,background:o.background,font:o.font},options:t||{}}:{session:o.session,persist:{snapshotKeyCache:V,defaultStyle:o.defaultStyle,baseStyle:o.baseStyle,image:o.image,resource:o.resource,background:o.background,font:o.font},options:e||t||{}}}function qe(e,t,n){if(!(!e.style||e.style.length===0))for(let r=0;r<e.style.length;r++){let i=e.style[r],a=n.getPropertyValue(i);a&&t.style.setProperty(i,a)}}async function H(e,t,n,r){if(e.tagName===`STYLE`)return;let i=Ke(n,r),a=i.options&&i.options.cache||`auto`;a!==`disabled`&&Ve(document.documentElement),a===`disabled`&&!i.session.__bumpedForDisabled&&(ze(),V.clear(),i.session.__bumpedForDisabled=!0);let{session:o,persist:s}=i;if(!o.styleCache.has(e)){let t=null;try{t=getComputedStyle(e)}catch{}o.styleCache.set(e,t||getComputedStyle(document.documentElement))}let c=o.styleCache.get(e);e.getAttribute?.(`style`)&&qe(e,t,c);let l=Ge(e,c,i.options);if(Xe(e)){let e=c.getPropertyValue(`min-width`);(!e||e===`auto`||e===`0px`)&&(l[`min-width`]=`0px`)}let u=We(l),d=s.snapshotKeyCache.get(u);d||(d=k(l,e.tagName?.toLowerCase()||`div`),s.snapshotKeyCache.set(u,d)),o.styleMap.set(t,d)}function Je(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLIFrameElement||e instanceof SVGElement||e instanceof HTMLObjectElement||e instanceof HTMLEmbedElement}function Ye(e){return e.backgroundImage&&e.backgroundImage!==`none`||e.backgroundColor&&e.backgroundColor!==`rgba(0, 0, 0, 0)`&&e.backgroundColor!==`transparent`||(parseFloat(e.borderTopWidth)||0)>0||(parseFloat(e.borderBottomWidth)||0)>0||(parseFloat(e.paddingTop)||0)>0||(parseFloat(e.paddingBottom)||0)>0?!0:(e.overflowBlock||e.overflowY||`visible`)!==`visible`}function Xe(e){let t=e.parentElement;if(!t)return!1;let n=getComputedStyle(t).display||``;return n.includes(`flex`)||n.includes(`grid`)}function Ze(e,t){if(e.textContent&&/\S/.test(e.textContent))return!0;let n=e.firstElementChild,r=e.lastElementChild;if(n&&n.tagName===`BR`||r&&r.tagName===`BR`)return!0;let i=e.scrollHeight;return i===0?!1:i>(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function Qe(e,t,n){if(e instanceof HTMLElement&&e.style&&e.style.height)return;let r=e.tagName&&e.tagName.toLowerCase();if(!r||![`div`,`section`,`article`,`main`,`aside`,`header`,`footer`,`nav`].includes(r))return;let i=parseFloat(t.height);if(Number.isFinite(i)&&e.scrollHeight>0&&Math.abs(i-e.scrollHeight)>2||t.aspectRatio&&t.aspectRatio!==`none`&&t.aspectRatio!==`auto`)return;let a=t.display||``;if(a.includes(`flex`)||a.includes(`grid`)||Je(e))return;let o=t.position;if(o===`absolute`||o===`fixed`||o===`sticky`||t.transform!==`none`||Ye(t)||Xe(e))return;let s=t.overflowX||t.overflow||`visible`,c=t.overflowY||t.overflow||`visible`;if(s!==`visible`||c!==`visible`)return;let l=t.clip;l&&l!==`auto`&&l!==`rect(auto, auto, auto, auto)`||t.visibility===`hidden`||t.opacity===`0`||Ze(e,t)&&(delete n.height,delete n[`block-size`])}se();var $e=[`fill`,`stroke`,`color`,`background-color`,`stop-color`],et=new Set([`symbol`,`defs`,`pattern`,`mask`,`clipPath`,`marker`,`linearGradient`,`radialGradient`,`filter`]);function tt(e){let t=e;for(;t&&t.nodeType===1;){if(t.namespaceURI===`http://www.w3.org/2000/svg`&&et.has(t.localName))return!0;t=t.parentNode}return!1}var nt=new Map;function rt(e,t){let n=t+`::`+e.toLowerCase(),r=nt.get(n);if(r)return r;let i=document,a=t===`http://www.w3.org/2000/svg`?i.createElementNS(t,e):i.createElement(e),o=i.createElement(`div`);o.style.cssText=`position:absolute;left:-99999px;top:-99999px;contain:strict;display:block;`,o.appendChild(a),i.documentElement.appendChild(o);let s=getComputedStyle(a),c={};for(let e of $e)c[e]=s.getPropertyValue(e)||``;return o.remove(),nt.set(n,c),c}function it(e,t){if(!(e instanceof Element)||!(t instanceof Element)||tt(e))return;let n=e.getAttribute?.(`style`),r=!!(n&&n.includes(`var(`));if(!r&&e.attributes?.length){let t=e.attributes;for(let e=0;e<t.length;e++){let n=t[e];if(n&&typeof n.value==`string`&&n.value.includes(`var(`)){r=!0;break}}}let i=null;if(r)try{i=getComputedStyle(e)}catch{}if(r){let n=e.style;if(n&&n.length){let e=new Set;for(let r=0;r<n.length;r++){let a=n[r];if(e.has(a))continue;e.add(a);let o=n.getPropertyValue(a);if(!o||!o.includes(`var(`))continue;let s=i&&i.getPropertyValue(a);if(s)try{t.style.setProperty(a,s.trim(),n.getPropertyPriority(a))}catch{}}}}if(r&&e.attributes?.length){let n=e.attributes;for(let e=0;e<n.length;e++){let r=n[e];if(!r||typeof r.value!=`string`||!r.value.includes(`var(`))continue;let a=r.name,o=i&&i.getPropertyValue(a);if(o)try{t.style.setProperty(a,o.trim())}catch{}}}if(!r){if(!i)try{i=getComputedStyle(e)}catch{i=null}if(!i)return;let n=e.namespaceURI||`html`,r=rt(e.tagName,n);for(let e of $e){let n=i.getPropertyValue(e)||``,a=r[e]||``;if(n&&n!==a)try{t.style.setProperty(e,n.trim())}catch{}}}}B(),B(),s(),w();function at(e,t,n){return Promise.all(e.map(e=>new Promise(r=>{function i(){I(n=>{!(n&&typeof n.timeRemaining==`function`)||n.timeRemaining()>0?t(e,r):i()},{fast:n})}i()})))}function ot(e){return e=e.trim(),!e||/:not\(\s*\[data-sd-slotted\]\s*\)\s*$/.test(e)?e:`${e}:not([data-sd-slotted])`}function st(e,t,n=!0){return e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>e.startsWith(`:where(`)||e.startsWith(`@`)?e:`:where(${t} ${n?ot(e):e})`).join(`, `)}function ct(e,t){return e?(e=e.replace(/:host\(([^)]+)\)/g,(e,n)=>`:where(${t}:is(${n.trim()}))`),e=e.replace(/:host\b/g,`:where(${t})`),e=e.replace(/:host-context\(([^)]+)\)/g,(e,n)=>`:where(:where(${n.trim()}) ${t})`),e=e.replace(/::slotted\(([^)]+)\)/g,(e,n)=>`:where(${t} ${n.trim()})`),e=e.replace(/(^|})(\s*)([^@}{]+){/g,(e,n,r,i)=>`${n}${r}${st(i,t,!0)}{`),e):``}function lt(e){return e.shadowScopeSeq=(e.shadowScopeSeq||0)+1,`s${e.shadowScopeSeq}`}function ut(e){let t=``;try{e.querySelectorAll(`style`).forEach(e=>{t+=(e.textContent||``)+`
3
+ `});let n=e.adoptedStyleSheets||[];for(let e of n)try{if(e&&e.cssRules)for(let n of e.cssRules)t+=n.cssText+`
4
+ `}catch{}}catch{}return t}function dt(e,t,n){if(!t)return;let r=document.createElement(`style`);r.setAttribute(`data-sd`,n),r.textContent=t,e.insertBefore(r,e.firstChild||null)}function ft(e,t){try{let n=e.currentSrc||e.src||``;if(!n)return;t.setAttribute(`src`,n),t.removeAttribute(`srcset`),t.removeAttribute(`sizes`),t.loading=`eager`,t.decoding=`sync`}catch{}}function pt(e){let t=new Set;if(!e)return t;let n=/var\(\s*(--[A-Za-z0-9_-]+)\b/g,r;for(;r=n.exec(e);)t.add(r[1]);return t}function mt(e,t){try{let n=getComputedStyle(e).getPropertyValue(t).trim();if(n)return n}catch{}try{let e=getComputedStyle(document.documentElement).getPropertyValue(t).trim();if(e)return e}catch{}return``}function ht(e,t,n){let r=[];for(let n of t){let t=mt(e,n);t&&r.push(`${n}: ${t};`)}return r.length?`${n}{${r.join(``)}}
5
+ `:``}function gt(e){e&&(e.nodeType===Node.ELEMENT_NODE&&e.setAttribute(`data-sd-slotted`,``),e.querySelectorAll&&e.querySelectorAll(`*`).forEach(e=>e.setAttribute(`data-sd-slotted`,``)))}async function _t(e,t=3){let n=()=>{try{return e.contentDocument||e.contentWindow?.document||null}catch{return null}},r=n(),i=0;for(;i<t&&(!r||!r.body&&!r.documentElement);)await new Promise(e=>setTimeout(e,0)),r=n(),i++;return r&&(r.body||r.documentElement)?r:null}function vt(e){let t=e.getBoundingClientRect(),n=0,r=0,i=0,a=0;try{let t=getComputedStyle(e);n=parseFloat(t.borderLeftWidth)||0,r=parseFloat(t.borderRightWidth)||0,i=parseFloat(t.borderTopWidth)||0,a=parseFloat(t.borderBottomWidth)||0}catch{}return{contentWidth:Math.max(0,Math.round(t.width-(n+r))),contentHeight:Math.max(0,Math.round(t.height-(i+a))),rect:t}}function U(e){let t=0,n=0;if(e.offsetWidth>0&&(t=e.offsetWidth),e.offsetHeight>0&&(n=e.offsetHeight),t===0||n===0)try{let r=getComputedStyle(e);if(t===0){let e=parseFloat(r.width);!isNaN(e)&&e>0&&(t=e)}if(n===0){let e=parseFloat(r.height);!isNaN(e)&&e>0&&(n=e)}}catch{}if(t===0||n===0)try{if(t===0){let n=parseFloat(e.getAttribute(`width`));!isNaN(n)&&n>0&&(t=n)}if(n===0){let t=parseFloat(e.getAttribute(`height`));!isNaN(t)&&t>0&&(n=t)}}catch{}if((t===0||n===0)&&(e.naturalWidth||e.naturalHeight))try{t===0&&e.naturalWidth>0&&(t=e.naturalWidth),n===0&&e.naturalHeight>0&&(n=e.naturalHeight)}catch{}return{width:t,height:n}}function yt(e,t,n){let r=e.defaultView,i=r?r.scrollX:0,a=r?r.scrollY:0,o=e.body?e.body.scrollLeft:0,s=e.body?e.body.scrollTop:0,c=e.documentElement?e.documentElement.scrollLeft:0,l=e.documentElement?e.documentElement.scrollTop:0,u=e.createElement(`style`);return u.setAttribute(`data-sd-iframe-pin`,``),u.textContent=`html, body {margin: 0 !important;padding: 0 !important;width: ${t}px !important;height: ${n}px !important;min-width: ${t}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(e.head||e.documentElement).appendChild(u),()=>{try{u.remove()}catch{}try{r&&typeof r.scrollTo==`function`&&r.scrollTo(i,a),e.body&&(e.body.scrollLeft=o,e.body.scrollTop=s),e.documentElement&&(e.documentElement.scrollLeft=c,e.documentElement.scrollTop=l)}catch{}}}async function bt(e,t,n){let r=await _t(e,3);if(!r)throw Error(`iframe document not accessible/ready`);let{contentWidth:i,contentHeight:a,rect:o}=vt(e),s=n?.snap;if(!s&&typeof window<`u`&&window.snapdom&&(s=window.snapdom),!s||typeof s.toPng!=`function`)throw Error(`[snapdom] iframe capture requires snapdom.toPng. Use snapdom(el) or pass options.snap. With ESM, assign window.snapdom = snapdom after import if using iframes.`);let c={...n,scale:1},l=yt(r,i,a),u;try{u=await s.toPng(r.documentElement,c)}finally{l()}u.style.display=`block`,u.style.width=`${i}px`,u.style.height=`${a}px`;let d=document.createElement(`div`);return t.nodeMap.set(d,e),H(e,d,t,n),d.style.overflow=`hidden`,d.style.display=`block`,d.style.width||(d.style.width=`${Math.round(o.width)}px`),d.style.height||(d.style.height=`${Math.round(o.height)}px`),d.appendChild(u),d}function xt(e){let{width:t,height:n}=U(e),r=e.getBoundingClientRect(),i;try{i=window.getComputedStyle(e)}catch{}let a=i?parseFloat(i.width):NaN,o=i?parseFloat(i.height):NaN,s=Math.round(t||r.width||0),c=Math.round(n||r.height||0),l=Number.isFinite(a)&&a>0?Math.round(a):Math.max(12,s||16),u=Number.isFinite(o)&&o>0?Math.round(o):Math.max(12,c||16),d=(e.type||`text`).toLowerCase()===`checkbox`,f=!!e.checked,p=!!e.indeterminate,m=Math.max(Math.min(l,u),12),h=`middle`;try{i&&i.verticalAlign&&(h=i.verticalAlign)}catch{}let g=document.createElement(`div`);g.setAttribute(`data-snapdom-input-replacement`,e.type||`checkbox`),g.style.cssText=`display:inline-block;width:${m}px;height:${m}px;vertical-align:${h};flex-shrink:0;line-height:0;`;let _=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);_.setAttribute(`width`,String(m)),_.setAttribute(`height`,String(m)),_.setAttribute(`viewBox`,`0 0 ${m} ${m}`),g.appendChild(_);function v(){let e=`#0a6ed1`;try{i&&(e=i.accentColor||i.color||e)}catch{}let t=m-2;if(_.innerHTML=``,d){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`rect`);if(n.setAttribute(`x`,`1`),n.setAttribute(`y`,`1`),n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`rx`,`2`),n.setAttribute(`ry`,`2`),n.setAttribute(`fill`,f?e:`none`),n.setAttribute(`stroke`,e),n.setAttribute(`stroke-width`,`2`),_.appendChild(n),f){let e=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);e.setAttribute(`d`,`M 3 ${m/2} L ${m/2-1} ${m-1-2} L ${m-1-2} 3`),e.setAttribute(`stroke`,`white`),e.setAttribute(`stroke-width`,`2`),e.setAttribute(`fill`,`none`),e.setAttribute(`stroke-linecap`,`round`),e.setAttribute(`stroke-linejoin`,`round`),_.appendChild(e)}else if(p){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`rect`),r=Math.max(6,t-4);n.setAttribute(`x`,String((m-r)/2)),n.setAttribute(`y`,String((m-2)/2)),n.setAttribute(`width`,String(r)),n.setAttribute(`height`,`2`),n.setAttribute(`fill`,e),n.setAttribute(`rx`,`1`),_.appendChild(n)}}else{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`circle`);if(t.setAttribute(`cx`,String(m/2)),t.setAttribute(`cy`,String(m/2)),t.setAttribute(`r`,String((m-2)/2)),t.setAttribute(`fill`,f?e:`none`),t.setAttribute(`stroke`,e),t.setAttribute(`stroke-width`,`2`),_.appendChild(t),f){let e=document.createElementNS(`http://www.w3.org/2000/svg`,`circle`),t=Math.max(2,(m-4)*.35);e.setAttribute(`cx`,String(m/2)),e.setAttribute(`cy`,String(m/2)),e.setAttribute(`r`,String(t)),e.setAttribute(`fill`,`white`),_.appendChild(e)}}g.style.setProperty(`width`,`${m}px`,`important`),g.style.setProperty(`height`,`${m}px`,`important`),g.style.setProperty(`min-width`,`${m}px`,`important`),g.style.setProperty(`min-height`,`${m}px`,`important`)}return v(),{el:g,applyVisual:v}}var St=new a(80);async function W(e){if(o.resource?.has(e))return o.resource.get(e);if(St.has(e))return St.get(e);let t=(async()=>{let t=await b(e,{as:`dataURL`,silent:!0});if(!t.ok||typeof t.data!=`string`)throw Error(`[snapDOM] Failed to read blob URL: ${e}`);return o.resource?.set(e,t.data),t.data})();St.set(e,t);try{let n=await t;return St.set(e,n),n}catch(t){throw St.delete(e),t}}var Ct=/\bblob:[^)"'\s]+/g;async function wt(e){if(!e||e.indexOf(`blob:`)===-1)return e;let t=Array.from(new Set(e.match(Ct)||[]));if(t.length===0)return e;let n=e;for(let e of t)try{let t=await W(e);n=n.split(e).join(t)}catch{}return n}function Tt(e){return typeof e==`string`&&e.startsWith(`blob:`)}function Et(e){return(e||``).split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.match(/^(\S+)(\s+.+)?$/);return t?{url:t[1],desc:t[2]||``}:null}).filter(Boolean)}function Dt(e){return e.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(`, `)}async function Ot(e,t=null){if(!e)return;let n=t,r=e.querySelectorAll?e.querySelectorAll(`img`):[];for(let e of r)try{let t=e.getAttribute(`src`)||e.currentSrc||``;if(Tt(t)){let n=await W(t);e.setAttribute(`src`,n)}let r=e.getAttribute(`srcset`);if(r&&r.includes(`blob:`)){let t=Et(r),i=!1;for(let e of t)if(Tt(e.url))try{e.url=await W(e.url),i=!0}catch(e){z(n,`blobUrlToDataUrl for srcset item failed`,e)}i&&e.setAttribute(`srcset`,Dt(t))}}catch(e){z(n,`resolveBlobUrls for img failed`,e)}let i=e.querySelectorAll?e.querySelectorAll(`image`):[];for(let e of i)try{let t=`http://www.w3.org/1999/xlink`,n=e.getAttribute(`href`)||e.getAttributeNS?.(t,`href`);if(Tt(n)){let r=await W(n);e.setAttribute(`href`,r),e.removeAttributeNS?.(t,`href`)}}catch(e){z(n,`resolveBlobUrls for SVG image href failed`,e)}let a=e.querySelectorAll?e.querySelectorAll(`[style*='blob:']`):[];for(let e of a)try{let t=e.getAttribute(`style`);if(t&&t.includes(`blob:`)){let n=await wt(t);e.setAttribute(`style`,n)}}catch(e){z(n,`replaceBlobUrls in inline style failed`,e)}let o=e.querySelectorAll?e.querySelectorAll(`style`):[];for(let e of o)try{let t=e.textContent||``;t.includes(`blob:`)&&(e.textContent=await wt(t))}catch(e){z(n,`replaceBlobUrls in style tag failed`,e)}for(let t of[`poster`]){let r=e.querySelectorAll?e.querySelectorAll(`[${t}^='blob:']`):[];for(let e of r)try{let n=e.getAttribute(t);Tt(n)&&e.setAttribute(t,await W(n))}catch(e){z(n,`resolveBlobUrls for ${t} failed`,e)}}}R();async function kt(e,t,n){if(!e)throw Error(`Invalid node`);let r=new Set,i=null,a=null;if(e.nodeType===Node.ELEMENT_NODE){let n=(e.localName||e.tagName||``).toLowerCase();if(e.id===`snapdom-sandbox`||e.hasAttribute(`data-snapdom-sandbox`)||ie.has(n))return null;if(n===`foreignobject`&&e.parentElement?.closest?.(`foreignObject`))return z(t,`Nested <foreignObject> skipped (SVG spec limitation — not rendered by browsers)`),null}if(e.nodeType===Node.TEXT_NODE||e.nodeType!==Node.ELEMENT_NODE)return e.cloneNode(!0);if(e.getAttribute(`data-capture`)===`exclude`){if(n.excludeMode===`hide`){let t=document.createElement(`div`),{width:n,height:r}=U(e),i=n||e.getBoundingClientRect().width||0,a=r||e.getBoundingClientRect().height||0;return t.style.cssText=`display:inline-block;width:${i}px;height:${a}px;visibility:hidden;`,t}else if(n.excludeMode===`remove`)return null}if(n.exclude&&Array.isArray(n.exclude))for(let t of n.exclude)try{if(e.matches?.(t)){if(n.excludeMode===`hide`){let t=document.createElement(`div`),{width:n,height:r}=U(e),i=n||e.getBoundingClientRect().width||0,a=r||e.getBoundingClientRect().height||0;return t.style.cssText=`display:inline-block;width:${i}px;height:${a}px;visibility:hidden;`,t}else if(n.excludeMode===`remove`)return null}}catch(e){console.warn(`Invalid selector in exclude option: ${t}`,e)}if(typeof n.filter==`function`)try{if(!n.filter(e)){if(n.filterMode===`hide`){let t=document.createElement(`div`),{width:n,height:r}=U(e),i=n||e.getBoundingClientRect().width||0,a=r||e.getBoundingClientRect().height||0;return t.style.cssText=`display:inline-block;width:${i}px;height:${a}px;visibility:hidden;`,t}else if(n.filterMode===`remove`)return null}}catch(e){console.warn(`Error in filter function:`,e)}if(e.tagName===`IFRAME`){let r=!1;try{r=!!(e.contentDocument||e.contentWindow?.document)}catch(e){z(t,`iframe same-origin probe failed`,e)}if(r)try{return await bt(e,t,n)}catch(e){console.warn(`[SnapDOM] iframe rasterization failed, fallback:`,e)}if(r||console.warn(`[snapdom] cross-origin <iframe> skipped (cannot access content). Use options.placeholders to show a placeholder instead.`,e),n.placeholders){let{width:r,height:i}=U(e),a=document.createElement(`div`);return a.style.cssText=`width:${r}px;height:${i}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,H(e,a,t,n),a}else{let{width:r,height:i}=U(e),a=document.createElement(`div`);return a.style.cssText=`display:inline-block;width:${r}px;height:${i}px;visibility:hidden;`,H(e,a,t,n),a}}if(e.getAttribute(`data-capture`)===`placeholder`){let r=e.cloneNode(!1);t.nodeMap.set(r,e),H(e,r,t,n);let i=document.createElement(`div`);return i.textContent=e.getAttribute(`data-placeholder-text`)||``,i.style.cssText=`color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;`,r.appendChild(i),r}if(e.tagName===`CANVAS`){let r=``;try{let t=e.getContext(`2d`,{willReadFrequently:!0});try{t&&t.getImageData(0,0,1,1)}catch{}if(await new Promise(e=>requestAnimationFrame(e)),r=e.toDataURL(`image/png`),!r||r===`data:,`){try{t&&t.getImageData(0,0,1,1)}catch{}if(await new Promise(e=>requestAnimationFrame(e)),r=e.toDataURL(`image/png`),!r||r===`data:,`){let t=document.createElement(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n&&(n.drawImage(e,0,0),r=t.toDataURL(`image/png`))}}}catch(e){z(t,`Canvas toDataURL failed, using empty/fallback`,e)}let i=document.createElement(`img`);try{i.decoding=`sync`,i.loading=`eager`}catch(e){z(t,`img decoding/loading hints failed`,e)}r&&(i.src=r),i.width=e.width,i.height=e.height;let{width:a,height:o}=U(e);return a>0&&(i.style.width=`${a}px`),o>0&&(i.style.height=`${o}px`),t.nodeMap.set(i,e),H(e,i,t,n),i}if(e.tagName===`VIDEO`){let r=``;try{let t=document.createElement(`canvas`);t.width=e.videoWidth||e.offsetWidth||320,t.height=e.videoHeight||e.offsetHeight||240;let n=t.getContext(`2d`);n&&(n.drawImage(e,0,0,t.width,t.height),r=t.toDataURL(`image/png`),(!r||r===`data:,`)&&(r=``))}catch(e){z(t,`Video frame capture failed, using poster fallback`,e)}let i=document.createElement(`img`);try{i.decoding=`sync`,i.loading=`eager`}catch{}r?i.src=r:e.poster&&(i.src=e.poster),i.width=e.videoWidth||e.offsetWidth||0,i.height=e.videoHeight||e.offsetHeight||0;let{width:a,height:o}=U(e);return a>0&&(i.style.width=`${a}px`),o>0&&(i.style.height=`${o}px`),i.style.objectFit=`contain`,t.nodeMap.set(i,e),H(e,i,t,n),i}let o;try{if(o=e.cloneNode(!1),o.attributes?.length)try{for(let e of o.attributes)/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/.test(e.value)&&o.setAttribute(e.name,e.value.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/g,``))}catch{}if(it(e,o),t.nodeMap.set(o,e),e.tagName===`IMG`){ft(e,o);try{let{width:t,height:n}=U(e),r=Math.round(t||0),i=Math.round(n||0);r&&(o.dataset.snapdomWidth=String(r)),i&&(o.dataset.snapdomHeight=String(i))}catch(e){z(t,`getUnscaledDimensions for IMG failed`,e)}try{let t=e.getAttribute(`style`)||``,n=window.getComputedStyle(e),r=e=>{let r=t.match(RegExp(`${e}\\s*:\\s*([^;]+)`,`i`)),i=r?r[1].trim():n.getPropertyValue(e);return/%|auto/i.test(String(i||``))},i=parseInt(o.dataset.snapdomWidth||`0`,10),a=parseInt(o.dataset.snapdomHeight||`0`,10),s=r(`width`)||!i,c=r(`height`)||!a;s&&i&&(o.style.width=`${i}px`),c&&a&&(o.style.height=`${a}px`);let l=n.getPropertyValue(`object-fit`),u=n.getPropertyValue(`object-position`);l&&l!==`fill`?(o.style.objectFit=l,u&&(o.style.objectPosition=u)):(i&&(o.style.minWidth=`${i}px`),a&&(o.style.minHeight=`${a}px`))}catch(e){z(t,`IMG dimension freeze failed`,e)}}}catch(t){throw console.error(`[Snapdom] Failed to clone node:`,e,t),t}let s=null;if(e instanceof HTMLTextAreaElement){let{width:t,height:n}=U(e),r=t||e.getBoundingClientRect().width||0,i=n||e.getBoundingClientRect().height||0;r&&(o.style.width=`${r}px`),i&&(o.style.height=`${i}px`)}if(e instanceof HTMLInputElement){let n=(e.type||`text`).toLowerCase();if((n===`checkbox`||n===`radio`)&&le()){let{el:n,applyVisual:r}=xt(e);t.nodeMap.set(n,e),s=r,o=n}else o.value=e.value,o.setAttribute(`value`,e.value),e.checked!==void 0&&(o.checked=e.checked,e.checked&&o.setAttribute(`checked`,``),e.indeterminate&&(o.indeterminate=e.indeterminate))}if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.value&&e.placeholder)try{let t=window.getComputedStyle(e,`::placeholder`),n=t&&t.color;if(n&&n!==`rgba(0, 0, 0, 0)`){let e=`snapdom-ph-`+(Math.random()*1e6|0);o.classList.add(e);let r=document.createElement(`style`);r.textContent=`.${e}::placeholder{color:${n}!important;opacity:${t.opacity||`1`}!important;}`,o.prepend(r)}}catch{}if(e instanceof HTMLSelectElement&&(i=e.value),e instanceof HTMLTextAreaElement&&(a=e.value),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement){e.disabled&&o.setAttribute(`disabled`,``),e.required&&o.setAttribute(`required`,``),e.readOnly&&o.setAttribute(`readonly`,``);let t=e;t.min!==void 0&&t.min!==``&&o.setAttribute(`min`,t.min),t.max!==void 0&&t.max!==``&&o.setAttribute(`max`,t.max),t.pattern!==void 0&&t.pattern!==``&&o.setAttribute(`pattern`,t.pattern);let n=e.getAttribute(`aria-invalid`);n!==null&&o.setAttribute(`aria-invalid`,n)}if(tt(e)||H(e,o,t,n),s&&s(),e instanceof SVGElement&&!tt(e)){let t=[`fill`,`stroke`,`stroke-width`,`stroke-dasharray`,`stroke-dashoffset`,`stroke-linecap`,`stroke-linejoin`,`stroke-miterlimit`,`opacity`,`fill-opacity`,`stroke-opacity`,`fill-rule`,`clip-rule`,`marker`,`marker-start`,`marker-mid`,`marker-end`,`visibility`,`display`];try{let n=window.getComputedStyle(e);for(let e of t){let t=n.getPropertyValue(e);t&&o.style.setProperty(e,t)}}catch{}}if(e.shadowRoot){let i=function(e,r){if(e.nodeType===Node.ELEMENT_NODE&&e.tagName===`STYLE`)return r(null);kt(e,t,n).then(e=>{r(e||null)}).catch(()=>{r(null)})};try{let t=e.shadowRoot.querySelectorAll(`slot`);for(let e of t){let t=[];try{t=e.assignedNodes?.({flatten:!0})||e.assignedNodes?.()||[]}catch{t=e.assignedNodes?.()||[]}for(let e of t)r.add(e)}}catch{}let a=lt(t),s=`[data-sd="${a}"]`;try{o.setAttribute(`data-sd`,a)}catch{}let c=ut(e.shadowRoot),l=ct(c,s),u=ht(e,pt(c),s);dt(o,u+l,a);let d=document.createDocumentFragment(),f=await at(Array.from(e.shadowRoot.childNodes),i,n.fast);d.append(...f.filter(e=>!!e)),o.appendChild(d)}if(e.tagName===`SLOT`){let r=function(e,r){kt(e,t,n).then(e=>{e&&gt(e),r(e||null)}).catch(()=>{r(null)})},i=e.assignedNodes?.({flatten:!0})||[],a=i.length>0?i:Array.from(e.childNodes),o=document.createDocumentFragment(),s=await at(Array.from(a),r,n.fast);return o.append(...s.filter(e=>!!e)),o}function c(e,i){if(r.has(e))return i(null);kt(e,t,n).then(e=>{i(e||null)}).catch(()=>{i(null)})}let l=await at(Array.from(e.childNodes),c,n.fast);if(o.append(...l.filter(e=>!!e)),i!==null&&o instanceof HTMLSelectElement){o.value=i;for(let e of o.options)e.value===i?e.setAttribute(`selected`,``):e.removeAttribute(`selected`)}return a!==null&&o instanceof HTMLTextAreaElement&&(o.textContent=a),o}B(),f(),s();var At=[/font\s*awesome/i,/material\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\s*icons/i,/remix\s*icons/i,/heroicons/i,/layui/i,/lucide/i],G=Object.assign({materialIconsFilled:`https://fonts.gstatic.com/s/materialicons/v48/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2`,materialIconsOutlined:`https://fonts.gstatic.com/s/materialiconsoutlined/v110/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUcel5euIg.woff2`,materialIconsRound:`https://fonts.gstatic.com/s/materialiconsround/v109/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmPq_HTTw.woff2`,materialIconsSharp:`https://fonts.gstatic.com/s/materialiconssharp/v110/oPWQ_lt5nv4pWNJpghLP75WiFR4kLh3kvmvRImcycg.woff2`},typeof window<`u`&&window.__SNAPDOM_ICON_FONTS__||{}),jt=[];function Mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Nt(e){let t=Array.isArray(e)?e:[e];for(let e of t)e instanceof RegExp?jt.push(e):typeof e==`string`?jt.push(new RegExp(Mt(e),`i`)):console.warn(`[snapdom] Ignored invalid iconFont value:`,e)}function K(e){let t=typeof e==`string`?e:``,n=[...At,...jt];for(let e of n)if(e instanceof RegExp&&e.test(t))return!0;return!!(/icon/i.test(t)||/glyph/i.test(t)||/symbols/i.test(t)||/feather/i.test(t)||/fontawesome/i.test(t))}function Pt(e=``){let t=String(e).toLowerCase();return/\bmaterial\s*icons\b/.test(t)||/\bmaterial\s*symbols\b/.test(t)}var Ft=new Map;function It(e=``){let t=Object.create(null),n=String(e||``),r=/['"]?\s*([A-Za-z]{3,4})\s*['"]?\s*([+-]?\d+(?:\.\d+)?)\s*/g,i;for(;i=r.exec(n);)t[i[1].toUpperCase()]=Number(i[2]);return t}async function Lt(e,t,n){let r=String(e||``),i=r.toLowerCase(),a=String(t||``).toLowerCase();if(/\bmaterial\s*icons\b/.test(i)&&!/\bsymbols\b/.test(i)||!/\bmaterial\s*symbols\b/.test(i))return{familyForMeasure:r,familyForCanvas:r};let o=n&&(n.FILL??n.fill),s=`outlined`;/\brounded\b/.test(a)||/\bround\b/.test(a)?s=`rounded`:/\bsharp\b/.test(a)?s=`sharp`:/\boutlined\b/.test(a)&&(s=`outlined`);let c=o===1,l=null;if(c&&(s===`outlined`&&G.materialIconsFilled?l={url:G.materialIconsFilled,alias:`snapdom-mi-filled`}:s===`rounded`&&G.materialIconsRound?l={url:G.materialIconsRound,alias:`snapdom-mi-round`}:s===`sharp`&&G.materialIconsSharp&&(l={url:G.materialIconsSharp,alias:`snapdom-mi-sharp`})),!l)return{familyForMeasure:r,familyForCanvas:r};if(!Ft.has(l.alias))try{let e=new FontFace(l.alias,`url(${l.url})`,{style:`normal`,weight:`400`});document.fonts.add(e),await e.load(),Ft.set(l.alias,!0)}catch{return{familyForMeasure:r,familyForCanvas:r}}let u=`"${l.alias}"`;return{familyForMeasure:u,familyForCanvas:u}}async function Rt(e=`Material Icons`,t=24){try{await Promise.all([document.fonts.load(`400 ${t}px "${String(e).replace(/["']/g,``)}"`),document.fonts.ready])}catch{}}function zt(e){let t=e.getPropertyValue(`-webkit-text-fill-color`)?.trim()||``,n=/^transparent$/i.test(t)||/rgba?\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(t);if(t&&!n&&t.toLowerCase()!==`currentcolor`)return t;let r=e.color?.trim();return r&&r!==`inherit`?r:`#000`}async function Bt(e,{family:t=`Material Icons`,weight:n=`normal`,fontSize:r=32,color:i=`#000`,variation:a=``,className:o=``}={}){let s=String(t||``).replace(/^['"]+|['"]+$/g,``),c=window.devicePixelRatio||1,{familyForMeasure:l,familyForCanvas:u}=await Lt(s,o,It(a));await Rt(u.replace(/^["']+|["']+$/g,``),r);let d=document.createElement(`span`);d.textContent=e,d.style.position=`absolute`,d.style.visibility=`hidden`,d.style.left=`-99999px`,d.style.whiteSpace=`nowrap`,d.style.fontFamily=l,d.style.fontWeight=String(n||`normal`),d.style.fontSize=`${r}px`,d.style.lineHeight=`1`,d.style.margin=`0`,d.style.padding=`0`,d.style.fontFeatureSettings=`'liga' 1`,d.style.fontVariantLigatures=`normal`,d.style.color=i,document.body.appendChild(d);let f=d.getBoundingClientRect(),p=Math.max(1,Math.ceil(f.width)),m=Math.max(1,Math.ceil(f.height));document.body.removeChild(d);let h=document.createElement(`canvas`);h.width=p*c,h.height=m*c;let g=h.getContext(`2d`);g.scale(c,c),g.font=`${n?`${n} `:``}${r}px ${u}`,g.textAlign=`left`,g.textBaseline=`top`,g.fillStyle=i;try{g.fontKerning=`normal`}catch{}return g.fillText(e,0,0),{dataUrl:h.toDataURL(),width:p,height:m}}async function Vt(e,t){if(!(e instanceof Element))return 0;let n=`.material-icons, [class*="material-symbols"]`,r=Array.from(e.querySelectorAll(n)).filter(e=>e&&e.textContent&&e.textContent.trim());if(r.length===0)return 0;let i=t instanceof Element?Array.from(t.querySelectorAll(n)).filter(e=>e&&e.textContent&&e.textContent.trim()):[],a=0;for(let e=0;e<r.length;e++){let t=r[e],n=i[e]||null;try{let e=getComputedStyle(n||t),r=e.fontFamily||`Material Icons`;if(!Pt(r))continue;let i=(n||t).textContent.trim();if(!i)continue;let o=parseInt(e.fontSize,10)||24,{dataUrl:s,width:c,height:l}=await Bt(i,{family:r,weight:e.fontWeight&&e.fontWeight!==`normal`?e.fontWeight:`normal`,fontSize:o,color:zt(e),variation:e.fontVariationSettings&&e.fontVariationSettings!==`normal`?e.fontVariationSettings:``,className:(n||t).className||``});t.textContent=``;let u=t.ownerDocument.createElement(`img`);u.src=s,u.alt=i,u.style.height=`${o}px`,u.style.width=`${Math.max(1,Math.round(c/l*o))}px`,u.style.objectFit=`contain`,u.style.verticalAlign=getComputedStyle(t).verticalAlign||`baseline`,t.appendChild(u),a++}catch{}}return a}w();async function Ht(e,t,n,r=32,i=`#000`){t=t.replace(/^['"]+|['"]+$/g,``);let a=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}let o=document.createElement(`span`);o.textContent=e,o.style.position=`absolute`,o.style.visibility=`hidden`,o.style.fontFamily=`"${t}"`,o.style.fontWeight=n||`normal`,o.style.fontSize=`${r}px`,o.style.lineHeight=`1`,o.style.whiteSpace=`nowrap`,o.style.padding=`0`,o.style.margin=`0`,document.body.appendChild(o);let s=o.getBoundingClientRect(),c=Math.ceil(s.width),l=Math.ceil(s.height);document.body.removeChild(o);let u=document.createElement(`canvas`);u.width=Math.max(1,c*a),u.height=Math.max(1,l*a);let d=u.getContext(`2d`);return d.scale(a,a),d.font=n?`${n} ${r}px "${t}"`:`${r}px "${t}"`,d.textAlign=`left`,d.textBaseline=`top`,d.fillStyle=i,d.fillText(e,0,0),{dataUrl:u.toDataURL(),width:c,height:l}}var Ut=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`emoji`,`math`,`fangsong`,`ui-serif`,`ui-sans-serif`,`ui-monospace`,`ui-rounded`]),Wt=[`katex`,`mathjax`,`mathml`];function Gt(e){if(!e)return``;for(let t of e.split(`,`)){let e=t.trim().replace(/^['"]+|['"]+$/g,``);if(e&&!Ut.has(e.toLowerCase()))return e}return``}function Kt(e){if(!e)return[];let t=[];for(let n of e.split(`,`)){let e=n.trim().replace(/^['"]+|['"]+$/g,``);e&&(Ut.has(e.toLowerCase())||t.push(e))}return t}function qt(e){let t=String(e??`400`).trim().toLowerCase();if(t===`normal`)return 400;if(t===`bold`)return 700;let n=parseInt(t,10);return Number.isFinite(n)?Math.min(900,Math.max(100,n)):400}function Jt(e){let t=String(e??`normal`).trim().toLowerCase();return t.startsWith(`italic`)?`italic`:t.startsWith(`oblique`)?`oblique`:`normal`}function Yt(e){let t=String(e??`100%`).match(/(\d+(?:\.\d+)?)\s*%/);return t?Math.max(50,Math.min(200,parseFloat(t[1]))):100}function Xt(e){let t=String(e||`400`).trim(),n=t.match(/^(\d{2,3})\s+(\d{2,3})$/);if(n){let e=qt(n[1]),t=qt(n[2]);return{min:Math.min(e,t),max:Math.max(e,t)}}let r=qt(t);return{min:r,max:r}}function Zt(e){let t=String(e||`normal`).trim().toLowerCase();return t===`italic`?{kind:`italic`}:t.startsWith(`oblique`)?{kind:`oblique`}:{kind:`normal`}}function Qt(e){let t=String(e||`100%`).trim(),n=t.match(/(\d+(?:\.\d+)?)\s*%\s+(\d+(?:\.\d+)?)\s*%/);if(n){let e=parseFloat(n[1]),t=parseFloat(n[2]);return{min:Math.min(e,t),max:Math.max(e,t)}}let r=t.match(/(\d+(?:\.\d+)?)\s*%/),i=r?parseFloat(r[1]):100;return{min:i,max:i}}function $t(e){return!e||typeof e!=`string`?``:e.replace(/\s+(variable|vf|v[0-9]+)$/i,``).trim().toLowerCase().replace(/\s+/g,`-`)}function en(e,t,n=[]){if(!e)return!1;try{let r=new URL(e,location.href);if(r.origin===location.origin)return!0;let i=r.host.toLowerCase();if([`fonts.googleapis.com`,`fonts.gstatic.com`,`use.typekit.net`,`p.typekit.net`,`kit.fontawesome.com`,`use.fontawesome.com`,`cdn.jsdelivr.net`,`unpkg.com`,`cdnjs.cloudflare.com`,`esm.sh`].some(e=>i.endsWith(e))||n.some(e=>i===e.toLowerCase()||i.endsWith(`.`+e.toLowerCase())))return!0;let a=(r.pathname+r.search).toLowerCase();if(/\bfont(s)?\b/.test(a)||/\.woff2?(\b|$)/.test(a)||Wt.some(e=>a.includes(e)))return!0;for(let e of t){let t=e.toLowerCase().replace(/\s+/g,`+`),n=e.toLowerCase().replace(/\s+/g,`-`),r=$t(e);if(a.includes(t)||a.includes(n)||r&&a.includes(r))return!0}return!1}catch{return!1}}function tn(e){let t=new Set;for(let n of e||[]){let e=String(n).split(`__`)[0]?.trim();e&&t.add(e)}return t}function nn(e,t){return e&&e.replace(/url\(\s*(['"]?)([^)'"]+)\1\s*\)/g,(e,n,r)=>{let i=(r||``).trim();if(!i||/^data:|^blob:|^https?:|^file:|^about:/i.test(i))return e;let a=i;try{a=new URL(i,t||location.href).href}catch{}return`url("${a}")`})}var rn=/@import\s+(?:url\(\s*(['"]?)([^)"']+)\1\s*\)|(['"])([^"']+)\3)([^;]*);/g,an=4;async function on(e,t,n){if(!e)return e;let r=new Set;function i(e,t){try{return new URL(e,t||location.href).href}catch{return e}}async function a(e,t,o=0){if(o>an)return console.warn(`[snapDOM] @import depth exceeded (${an}) at ${t}`),e;let s=``,c=0,l;for(;l=rn.exec(e);){s+=e.slice(c,l.index),c=rn.lastIndex;let u=i((l[2]||l[4]||``).trim(),t);if(r.has(u)){console.warn(`[snapDOM] Skipping circular @import: ${u}`);continue}r.add(u);let d=``;try{let e=await b(u,{as:`text`,useProxy:n,silent:!0});e.ok&&typeof e.data==`string`&&(d=e.data)}catch{}d?(d=nn(d,u),d=await a(d,u,o+1),s+=`
6
+ /* inlined: ${u} */
7
+ ${d}
8
+ `):s+=l[0]}return s+=e.slice(c),s}let o=nn(e,t||location.href);return o=await a(o,t||location.href,0),o}var sn=/url\((["']?)([^"')]+)\1\)/g,cn=/@font-face[^{}]*\{[^}]*\}/g;function ln(e){if(!e)return[];let t=[],n=e.split(`,`).map(e=>e.trim()).filter(Boolean);for(let e of n){let n=e.match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!n)continue;let r=n[1],i=n[2],a=e=>e.includes(`?`)?[parseInt(e.replace(/\?/g,`0`),16),parseInt(e.replace(/\?/g,`F`),16)]:parseInt(e,16);if(i){let e=a(r),n=a(i),o=Array.isArray(e)?e[0]:e,s=Array.isArray(n)?n[1]:n;t.push([Math.min(o,s),Math.max(o,s)])}else{let e=a(r);Array.isArray(e)?t.push([e[0],e[1]]):t.push([e,e])}}return t}function un(e,t){if(!t.length||!e||e.size===0)return!0;for(let n of e)for(let[e,r]of t)if(n>=e&&n<=r)return!0;return!1}function dn(e,t){let n=[];if(!e)return n;for(let r of e.matchAll(sn)){let e=(r[2]||``).trim();if(!(!e||e.startsWith(`data:`))){if(!/^https?:/i.test(e))try{e=new URL(e,t||location.href).href}catch{}n.push(e)}}return n}async function fn(e,t,n=``){let r=e;for(let i of e.matchAll(sn)){let e=c(i[0]);if(!e)continue;let a=e;if(!a.startsWith(`http`)&&!a.startsWith(`data:`))try{a=new URL(a,t||location.href).href}catch{}if(!K(a)){if(o.resource?.has(a)){o.font?.add(a),r=r.replace(i[0],`url(${o.resource.get(a)})`);continue}if(!o.font?.has(a))try{let e=await b(a,{as:`dataURL`,useProxy:n,silent:!0});if(e.ok&&typeof e.data==`string`){let t=e.data;o.resource?.set(a,t),o.font?.add(a),r=r.replace(i[0],`url(${t})`)}}catch{console.warn(`[snapDOM] Failed to fetch font resource:`,a)}}}return r}function pn(e){if(!e.length)return null;let t=(t,n)=>e.some(([e,r])=>!(r<t||e>n)),n=t(0,255)||t(305,305),r=t(256,591)||t(7680,7935),i=t(880,1023),a=t(1024,1279);return t(7840,7929)||t(258,259)||t(416,417)||t(431,432)?`vietnamese`:a?`cyrillic`:i?`greek`:r?`latin-ext`:n?`latin`:null}function mn(e={}){let t=new Set((e.families||[]).map(e=>String(e).toLowerCase())),n=new Set((e.domains||[]).map(e=>String(e).toLowerCase())),r=new Set((e.subsets||[]).map(e=>String(e).toLowerCase()));return(e,i)=>{if(t.size&&t.has(e.family.toLowerCase()))return!0;if(n.size)for(let t of e.srcUrls)try{if(n.has(new URL(t).host.toLowerCase()))return!0}catch{}if(r.size){let e=pn(i);if(e&&r.has(e))return!0}return!1}}function hn(e){if(!e)return e;let t=/@font-face[^{}]*\{[^}]*\}/gi,n=new Set,r=[];for(let i of e.match(t)||[]){let e=Gt(i.match(/font-family:\s*([^;]+);/i)?.[1]||``),t=(i.match(/font-weight:\s*([^;]+);/i)?.[1]||`400`).trim(),a=(i.match(/font-style:\s*([^;]+);/i)?.[1]||`normal`).trim(),o=(i.match(/font-stretch:\s*([^;]+);/i)?.[1]||`100%`).trim(),s=(i.match(/unicode-range:\s*([^;]+);/i)?.[1]||``).trim(),c=(i.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||``).trim(),l=dn(c,location.href),u=l.length?l.map(e=>String(e).toLowerCase()).sort().join(`|`):c.toLowerCase(),d=[String(e||``).toLowerCase(),t,a,o,s.toLowerCase(),u].join(`|`);n.has(d)||(n.add(d),r.push(i))}if(r.length===0)return e;let i=0;return e.replace(t,()=>r[i++]||``)}function gn(e,t,n,r,i){return`fonts-embed-css::req=${Array.from(e||[]).sort().join(`|`)}::ex=${t?JSON.stringify({families:(t.families||[]).map(e=>String(e).toLowerCase()).sort(),domains:(t.domains||[]).map(e=>String(e).toLowerCase()).sort(),subsets:(t.subsets||[]).map(e=>String(e).toLowerCase()).sort()}):``}::lf=${(n||[]).map(e=>`${(e.family||``).toLowerCase()}::${e.weight||`normal`}::${e.style||`normal`}::${e.src||``}`).sort().join(`|`)}::px=${r||``}::fd=${(i||[]).map(e=>String(e).toLowerCase()).sort().join(`|`)}`}async function _n(e,t,n,r){let i;try{i=e.cssRules||[]}catch{return}let a=(e,t)=>{try{return new URL(e,t||location.href).href}catch{return e}};for(let e of i){if(e.type===CSSRule.IMPORT_RULE&&e.styleSheet){let i=e.href?a(e.href,t):t;if(r.depth>=an){console.warn(`[snapDOM] CSSOM import depth exceeded (${an}) at ${i}`);continue}if(i&&r.visitedSheets.has(i)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${i}`);continue}i&&r.visitedSheets.add(i);let o={...r,depth:(r.depth||0)+1};await _n(e.styleSheet,i,n,o);continue}if(e.type===CSSRule.FONT_FACE_RULE){let i=Gt((e.style.getPropertyValue(`font-family`)||``).trim());if(!i||K(i))continue;let a=(e.style.getPropertyValue(`font-weight`)||`400`).trim(),o=(e.style.getPropertyValue(`font-style`)||`normal`).trim(),s=(e.style.getPropertyValue(`font-stretch`)||`100%`).trim(),c=(e.style.getPropertyValue(`src`)||``).trim(),l=(e.style.getPropertyValue(`unicode-range`)||``).trim();if(!r.faceMatchesRequired(i,o,a,s))continue;let u=ln(l);if(!un(r.usedCodepoints,u))continue;let d={family:i,weightSpec:a,styleSpec:o,stretchSpec:s,unicodeRange:l,srcRaw:c,srcUrls:dn(c,t||location.href),href:t||location.href};if(r.simpleExcluder&&r.simpleExcluder(d,u))continue;/url\(/i.test(c)?await n(`@font-face{font-family:${i};src:${await fn(c,t||location.href,r.useProxy)};font-style:${o};font-weight:${a};font-stretch:${s};${l?`unicode-range:${l};`:``}}`):await n(`@font-face{font-family:${i};src:${c};font-style:${o};font-weight:${a};font-stretch:${s};${l?`unicode-range:${l};`:``}}`)}}}async function vn({required:e,usedCodepoints:t,exclude:n=void 0,localFonts:r=[],useProxy:i=``,fontStylesheetDomains:a=[]}={}){e instanceof Set||(e=new Set),t instanceof Set||(t=new Set);let s=new Map;for(let t of e){let[e,n,r,i]=String(t).split(`__`);if(!e)continue;let a=s.get(e)||[];a.push({w:parseInt(n,10),s:r,st:parseInt(i,10)}),s.set(e,a)}function c(e,t,n,r){if(!s.has(e))return!1;let i=s.get(e),a=Xt(n),o=Zt(t),c=Qt(r),l=a.min!==a.max,u=a.min,d=e=>o.kind===`normal`&&e===`normal`||o.kind!==`normal`&&(e===`italic`||e===`oblique`),f=!1;for(let e of i){let t=l?e.w>=a.min&&e.w<=a.max:e.w===u,n=d(Jt(e.s)),r=e.st>=c.min&&e.st<=c.max;if(t&&n&&r){f=!0;break}}if(f)return!0;if(!l)for(let e of i){let t=d(Jt(e.s)),n=e.st>=c.min&&e.st<=c.max;if(Math.abs(u-e.w)<=300&&t&&n)return!0}if(!l&&o.kind===`normal`&&i.some(e=>Jt(e.s)!==`normal`))for(let e of i){let t=Math.abs(u-e.w)<=300,n=e.st>=c.min&&e.st<=c.max;if(t&&n)return!0}return!1}let l=mn(n),u=gn(e,n,r,i,a);if(o.resource?.has(u))return o.resource.get(u);let d=tn(e),f=[],p=rn;for(let e of document.querySelectorAll(`style`)){let t=e.textContent||``;for(let e of t.matchAll(p)){let t=(e[2]||e[4]||``).trim();!t||K(t)||document.querySelector(`link[rel="stylesheet"][href="${t}"]`)||f.push(t)}}f.length&&await Promise.all(f.map(e=>new Promise(t=>{if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return t(null);let n=document.createElement(`link`);n.rel=`stylesheet`,n.href=e,n.setAttribute(`data-snapdom`,`injected-import`),n.onload=()=>t(n),n.onerror=()=>t(null),document.head.appendChild(n)})));let m=``,h=Array.from(document.querySelectorAll(`link[rel="stylesheet"]`)).filter(e=>!!e.href);for(let e of h)try{if(K(e.href))continue;let r=``,o=!1;try{o=new URL(e.href,location.href).origin===location.origin}catch{}if(!o){let t=Array.isArray(a)?a:[];if(!en(e.href,d,t))continue}if(o){let t=Array.from(document.styleSheets).find(t=>t.href===e.href);if(t)try{let e=t.cssRules||[];r=Array.from(e).map(e=>e.cssText).join(``)}catch{}}if(!r){let t=await b(e.href,{as:`text`,useProxy:i});if(t?.ok&&typeof t.data==`string`&&(r=t.data),K(e.href))continue}r=await on(r,e.href,i);let s=``;for(let a of r.match(cn)||[]){let r=Gt((a.match(/font-family:\s*([^;]+);/i)?.[1]||``).trim());if(!r||K(r))continue;let o=(a.match(/font-weight:\s*([^;]+);/i)?.[1]||`400`).trim(),u=(a.match(/font-style:\s*([^;]+);/i)?.[1]||`normal`).trim(),d=(a.match(/font-stretch:\s*([^;]+);/i)?.[1]||`100%`).trim(),f=(a.match(/unicode-range:\s*([^;]+);/i)?.[1]||``).trim(),p=(a.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1]||``).trim(),m=dn(p,e.href);if(!c(r,u,o,d))continue;let h=ln(f);if(!un(t,h))continue;let g={family:r,weightSpec:o,styleSpec:u,stretchSpec:d,unicodeRange:f,srcRaw:p,srcUrls:m,href:e.href};if(n&&l(g,h))continue;let _=/url\(/i.test(p)?await fn(a,e.href,i):a;s+=_}s.trim()&&(m+=s)}catch{console.warn(`[snapDOM] Failed to process stylesheet:`,e.href)}let g={requiredIndex:s,usedCodepoints:t,faceMatchesRequired:c,simpleExcluder:n?mn(n):null,useProxy:i,visitedSheets:new Set,depth:0};for(let e of document.styleSheets)if(!(e.href&&h.some(t=>t.href===e.href)))try{let t=e.href||location.origin+`/`;t&&g.visitedSheets.add(t),await _n(e,t,async e=>{m+=e},g)}catch{}try{for(let e of document.fonts||[]){if(!e||!e.family||e.status!==`loaded`||!e._snapdomSrc)continue;let t=String(e.family).replace(/^['"]+|['"]+$/g,``);if(K(t)||!s.has(t)||n?.families&&n.families.some(e=>String(e).toLowerCase()===t.toLowerCase()))continue;let r=e._snapdomSrc;if(!String(r).startsWith(`data:`)){if(o.resource?.has(e._snapdomSrc))r=o.resource.get(e._snapdomSrc),o.font?.add(e._snapdomSrc);else if(!o.font?.has(e._snapdomSrc))try{let t=await b(e._snapdomSrc,{as:`dataURL`,useProxy:i,silent:!0});if(t.ok&&typeof t.data==`string`)r=t.data,o.resource?.set(e._snapdomSrc,r),o.font?.add(e._snapdomSrc);else continue}catch{console.warn(`[snapDOM] Failed to fetch dynamic font src:`,e._snapdomSrc);continue}}m+=`@font-face{font-family:'${t}';src:url(${r});font-style:${e.style||`normal`};font-weight:${e.weight||`normal`};}`}}catch{}for(let e of r){if(!e||typeof e!=`object`)continue;let t=String(e.family||``).replace(/^['"]+|['"]+$/g,``);if(!t||K(t)||!s.has(t)||n?.families&&n.families.some(e=>String(e).toLowerCase()===t.toLowerCase()))continue;let r=e.weight==null?`normal`:String(e.weight),a=e.style==null?`normal`:String(e.style),c=e.stretchPct==null?`100%`:`${e.stretchPct}%`,l=String(e.src||``),u=l;if(!u.startsWith(`data:`)){if(o.resource?.has(l))u=o.resource.get(l),o.font?.add(l);else if(!o.font?.has(l))try{let e=await b(l,{as:`dataURL`,useProxy:i,silent:!0});if(e.ok&&typeof e.data==`string`)u=e.data,o.resource?.set(l,u),o.font?.add(l);else continue}catch{console.warn(`[snapDOM] Failed to fetch localFonts src:`,l);continue}}m+=`@font-face{font-family:'${t}';src:url(${u});font-style:${a};font-weight:${r};font-stretch:${c};}`}return m&&(m=hn(m),o.resource?.set(u,m)),m}function yn(e){let t=new Set;if(!e)return t;let n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null),r=e=>{let n=Kt(e.fontFamily);if(n.length)for(let r of n)t.add(((e,t,n)=>`${r}__${qt(e)}__${Jt(t)}__${Yt(n)}`)(e.fontWeight,e.fontStyle,e.fontStretch))};r(getComputedStyle(e));let i=getComputedStyle(e,`::before`);i&&i.content&&i.content!==`none`&&r(i);let a=getComputedStyle(e,`::after`);for(a&&a.content&&a.content!==`none`&&r(a);n.nextNode();){let e=n.currentNode;r(getComputedStyle(e));let t=getComputedStyle(e,`::before`);t&&t.content&&t.content!==`none`&&r(t);let i=getComputedStyle(e,`::after`);i&&i.content&&i.content!==`none`&&r(i)}return t}function bn(e){let t=new Set,n=e=>{if(e)for(let n of e)t.add(n.codePointAt(0))},r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;r.nextNode();){let e=r.currentNode;if(e.nodeType===Node.TEXT_NODE)n(e.nodeValue||``);else if(e.nodeType===Node.ELEMENT_NODE){let r=e;for(let e of[`::before`,`::after`]){let i=getComputedStyle(r,e)?.getPropertyValue(`content`);if(!(!i||i===`none`))if(/^"/.test(i)||/^'/.test(i))n(i.slice(1,-1));else{let e=i.match(/\\[0-9A-Fa-f]{1,6}/g);if(e)for(let n of e)try{t.add(parseInt(n.slice(1),16))}catch{}}}}}return t}async function xn(e,t=2){try{await document.fonts.ready}catch{}let n=Array.from(e||[]).filter(Boolean);if(n.length===0)return;let r=()=>{let e=document.createElement(`div`);e.style.cssText=`position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;`;for(let t of n){let n=document.createElement(`span`);n.textContent=`AaBbGg1234ÁÉÍÓÚçñ—∞`,n.style.fontFamily=`"${t}"`,n.style.fontWeight=`700`,n.style.fontStyle=`italic`,n.style.fontSize=`32px`,n.style.lineHeight=`1`,n.style.whiteSpace=`nowrap`,n.style.margin=`0`,n.style.padding=`0`,e.appendChild(n)}document.body.appendChild(e),e.offsetWidth,document.body.removeChild(e)};for(let e=0;e<Math.max(1,t);e++)r(),await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e)))}s();function Sn(e){return/\bcounter\s*\(|\bcounters\s*\(/.test(e||``)}function Cn(e,t=!1){let n=``,r=Math.max(1,e);for(;r>0;)r--,n=String.fromCharCode(97+r%26)+n,r=Math.floor(r/26);return t?n.toUpperCase():n}function wn(e,t=!0){let n=[[1e3,`M`],[900,`CM`],[500,`D`],[400,`CD`],[100,`C`],[90,`XC`],[50,`L`],[40,`XL`],[10,`X`],[9,`IX`],[5,`V`],[4,`IV`],[1,`I`]],r=Math.max(1,Math.min(3999,e)),i=``;for(let[e,t]of n)for(;r>=e;)i+=t,r-=e;return t?i:i.toLowerCase()}function Tn(e,t){switch((t||`decimal`).toLowerCase()){case`decimal`:return String(e);case`decimal-leading-zero`:{let t=Math.abs(e);return(e<0?`-`:``)+(t<10?`0`:``)+String(t)}case`lower-alpha`:return Cn(e,!1);case`upper-alpha`:return Cn(e,!0);case`lower-roman`:return wn(e,!1);case`upper-roman`:return wn(e,!0);default:return String(e)}}function En(e){let t=()=>o?.session?.__counterEpoch??0,n=t(),r=new WeakMap,i=e instanceof Document?e.documentElement:e,a=e=>e&&e.tagName===`LI`,s=e=>{let t=0,n=e?.parentElement;if(!n)return 0;for(let r of n.children){if(r===e)break;r.tagName===`LI`&&t++}return t},c=e=>{let t=new Map;for(let[n,r]of e)t.set(n,r.slice());return t},l=(e,t,n)=>{let r=c(e),i;try{i=n.style?.counterReset||getComputedStyle(n).counterReset}catch{}if(i&&i!==`none`)for(let e of i.split(`,`)){let n=e.trim().split(/\s+/),i=n[0],a=Number.isFinite(Number(n[1]))?Number(n[1]):0;if(!i)continue;let o=t.get(i);if(o&&o.length){let e=o.slice();e.push(a),r.set(i,e)}else r.set(i,[a])}let o;try{o=n.style?.counterSet||getComputedStyle(n).counterSet}catch{}if(o&&o!==`none`)for(let e of o.split(`,`)){let t=e.trim().split(/\s+/),n=t[0],i=Number.isFinite(Number(t[1]))?Number(t[1]):0;if(!n)continue;let a=r.get(n)||[];a.length===0&&a.push(0),a[a.length-1]=i,r.set(n,a)}let l;try{l=n.style?.counterIncrement||getComputedStyle(n).counterIncrement}catch{}if(l&&l!==`none`)for(let e of l.split(`,`)){let t=e.trim().split(/\s+/),n=t[0],i=Number.isFinite(Number(t[1]))?Number(t[1]):1;if(!n)continue;let a=r.get(n)||[];a.length===0&&a.push(0),a[a.length-1]+=i,r.set(n,a)}try{if(getComputedStyle(n).display===`list-item`&&a(n)){let e=n.parentElement,t=1;if(e&&e.tagName===`OL`){let r=e.getAttribute(`start`),i=Number.isFinite(Number(r))?Number(r):1,a=s(n),o=n.getAttribute(`value`);t=Number.isFinite(Number(o))?Number(o):i+a}else t=1+s(n);let i=r.get(`list-item`)||[];i.length===0&&i.push(0),i[i.length-1]=t,r.set(`list-item`,i)}}catch{}return r},u=(e,t,n)=>{let i=l(n,t,e);r.set(e,i);let a=i;for(let t of e.children)a=u(t,i,a);let o=new Map;for(let[e,t]of n){let n=t.length,r=a.get(e);o.set(e,r&&r.length?r.slice(0,n):t.slice())}for(let[e,n]of a)!o.has(e)&&n.length&&!t.has(e)&&o.set(e,n.slice(0,1));return o},d=new Map;u(i,d,d);function f(){let e=t();if(e!==n){n=e;let t=new Map;u(i,t,t)}}return{get(e,t){f();let n=r.get(e)?.get(t);return n&&n.length?n[n.length-1]:0},getStack(e,t){f();let n=r.get(e)?.get(t);return n?n.slice():[]}}}function Dn(e,t,n){if(!e||e===`none`)return e;try{return e.replace(/\b(counter|counters)\s*\(([^)]+)\)/g,(e,r,i)=>{let a=String(i).split(`,`).map(e=>e.trim());if(r===`counter`){let e=a[0]?.replace(/^["']|["']$/g,``),r=(a[1]||`decimal`).toLowerCase();return Tn(n.get(t,e),r)}else{let e=a[0]?.replace(/^["']|["']$/g,``),r=a[1]?.replace(/^["']|["']$/g,``)??``,i=(a[2]||`decimal`).toLowerCase(),o=n.getStack(t,e);return o.length?o.map(e=>Tn(e,i)).join(r):``}})}catch{return`- `}}w(),s();var q=new WeakMap,On=1e3;function kn(e,t){let n=jn(e);return t?(t.__pseudoPreflightFp!==n&&(t.__pseudoPreflight=Nn(e),t.__pseudoPreflightFp=n),!!t.__pseudoPreflight):Nn(e)}function An(e){try{return e&&e.cssRules?e.cssRules:null}catch{return null}}function jn(e){let t=e.querySelectorAll(`style,link[rel~="stylesheet"]`),n=`n:${t.length}|`,r=0;for(let e=0;e<t.length;e++){let i=t[e];if(i.tagName===`STYLE`){let e=i.textContent?i.textContent.length:0;n+=`S${e}|`;let t=i.sheet,a=t?An(t):null;a&&(r+=a.length)}else{let e=i.getAttribute(`href`)||``,t=i.getAttribute(`media`)||`all`;n+=`L${e}|m:${t}|`;let a=i.sheet,o=a?An(a):null;o&&(r+=o.length)}}let i=e.adoptedStyleSheets;return n+=`ass:${Array.isArray(i)?i.length:0}|tr:${r}`,n}function Mn(e,t,n){let r=An(e);if(!r)return!1;for(let e=0;e<r.length;e++){if(n.budget<=0)return!1;let i=r[e],a=i&&i.cssText?i.cssText:``;n.budget--;for(let e of t)if(a.includes(e))return!0;if(i&&i.cssRules&&i.cssRules.length)for(let e=0;e<i.cssRules.length&&n.budget>0;e++){let r=i.cssRules[e],a=r&&r.cssText?r.cssText:``;n.budget--;for(let e of t)if(a.includes(e))return!0}if(n.budget<=0)return!1}return!1}function Nn(e=document){let t=jn(e),n=q.get(e);if(n&&n.fingerprint===t)return n.result;let r=[`::before`,`::after`,`::first-letter`,`:before`,`:after`,`:first-letter`,`counter(`,`counters(`,`counter-increment`,`counter-reset`],i=e.querySelectorAll(`style`);for(let n=0;n<i.length;n++){let a=i[n].textContent||``;for(let n of r)if(a.includes(n))return q.set(e,{fingerprint:t,result:!0}),!0}let a=e.adoptedStyleSheets;if(Array.isArray(a)&&a.length){let n={budget:On};try{for(let i of a)if(Mn(i,r,n))return q.set(e,{fingerprint:t,result:!0}),!0}catch{}}{let n=e.querySelectorAll(`style,link[rel~="stylesheet"]`),i={budget:On};for(let a=0;a<n.length&&i.budget>0;a++){let o=n[a],s=null;if(o.tagName,s=o.sheet||null,s&&Mn(s,r,i))return q.set(e,{fingerprint:t,result:!0}),!0}}return e.querySelector(`[style*="counter("], [style*="counters("]`)?(q.set(e,{fingerprint:t,result:!0}),!0):(q.set(e,{fingerprint:t,result:!1}),!1)}var J=new WeakMap,Pn=-1;function Fn(e){if(!e)return``;let t=[],n=/"([^"]*)"/g,r=0,i;for(;i=n.exec(e);){let a=e.slice(r,i.index).trim();a&&t.push(a),t.push(i[1]),r=n.lastIndex}let a=e.slice(r).trim();return a&&t.push(a),t.join(``)}function In(e,t){let n=e.parentElement,r=n?J.get(n):null;return r?{get(e,n){let i=t.get(e,n),a=r.get(n);return typeof a==`number`?Math.max(i,a):i},getStack(e,n){let i=t.getStack(e,n);if(!i.length)return i;let a=r.get(n);if(typeof a==`number`){let e=i.slice();return e[e.length-1]=Math.max(e[e.length-1],a),e}return i}}:t}function Ln(e,t,n){let r=new Map;function i(e){let t=[];if(!e||e===`none`)return t;for(let n of String(e).split(`,`)){let e=n.trim().split(/\s+/),r=e[0],i=Number.isFinite(Number(e[1]))?Number(e[1]):void 0;r&&t.push({name:r,num:i})}return t}let a=i(t?.counterReset),o=i(t?.counterIncrement);function s(t){if(r.has(t))return r.get(t).slice();let i=n.getStack(e,t);i=i.length?i.slice():[];let s=a.find(e=>e.name===t);if(s){let e=Number.isFinite(s.num)?s.num:0;i=i.length?[...i,e]:[e]}let c=o.find(e=>e.name===t);if(c){let e=Number.isFinite(c.num)?c.num:1;i.length===0&&(i=[0]),i[i.length-1]+=e}return r.set(t,i.slice()),i}return{get(e,t){let n=s(t);return n.length?n[n.length-1]:0},getStack(e,t){return s(t)},__incs:o}}function Rn(e,t,n){let r;try{r=M(e,t)}catch{}let i=r?.content;if(!i||i===`none`||i===`normal`)return{text:``,incs:[]};let a=In(e,n),o=Ln(e,r,a);return{text:Fn(Sn(i)?Dn(i,e,o):i),incs:o.__incs||[]}}async function zn(e,t,n,r){if(!(e instanceof Element)||!(t instanceof Element)||!kn(e.ownerDocument||document,n))return;let i=o?.session?.__counterEpoch??0;if(Pn!==i&&(J=new WeakMap,n&&(n.__counterCtx=null),Pn=i),!n.__counterCtx)try{n.__counterCtx=En(e.ownerDocument||document)}catch(e){z(n,`buildCounterContext failed`,e)}let a=n.__counterCtx;for(let i of[`::before`,`::after`,`::first-letter`])try{let o=M(e,i);if(!o||o.content===`none`&&o.backgroundImage===`none`&&o.backgroundColor===`transparent`&&(o.borderStyle===`none`||parseFloat(o.borderWidth)===0)&&(!o.transform||o.transform===`none`)&&o.display===`inline`)continue;if(i===`::first-letter`){let r=M(e),i=(r?.display||``).toLowerCase();if(i.includes(`flex`)||i.includes(`grid`)||!(o.color!==r.color||o.fontSize!==r.fontSize||o.fontWeight!==r.fontWeight||o.fontFamily!==r.fontFamily||o.fontStyle!==r.fontStyle||o.textTransform!==r.textTransform||o.float!==r.float||o.paddingTop!==r.paddingTop||o.paddingRight!==r.paddingRight||o.paddingBottom!==r.paddingBottom||o.paddingLeft!==r.paddingLeft||o.marginTop!==r.marginTop||o.marginRight!==r.marginRight||o.marginBottom!==r.marginBottom||o.marginLeft!==r.marginLeft))continue;let a=Array.from(t.childNodes).find(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim().length>0);if(!a)continue;let s=a.textContent,c=s.match(/^([^\p{L}\p{N}\s]*[\p{L}\p{N}](?:['’])?)/u)?.[0],l=s.slice(c?.length||0);if(!c||/[\uD800-\uDFFF]/.test(c))continue;let u=document.createElement(`span`);u.textContent=c,u.dataset.snapdomPseudo=`::first-letter`;let d=k(ne(o),`span`);n.styleMap.set(u,d);let f=document.createTextNode(l);t.replaceChild(f,a),t.insertBefore(u,f);continue}let s=o.content??``,l=s===``||s===`none`||s===`normal`,{text:d,incs:f}=Rn(e,i,a),p=o.backgroundImage,m=o.backgroundColor,h=o.fontFamily,g=parseInt(o.fontSize)||32,_=parseInt(o.fontWeight)||!1,v=o.color||`#000`,y=o.borderStyle,x=parseFloat(o.borderWidth),S=o.transform,C=K(h),w=!l&&d!==``,E=p&&p!==`none`,D=m&&m!==`transparent`&&m!==`rgba(0, 0, 0, 0)`,O=y&&y!==`none`&&x>0,A=S&&S!==`none`;if(!(w||E||D||O||A)){if(f&&f.length&&e.parentElement){let t=J.get(e.parentElement)||new Map;for(let{name:n}of f){if(!n)continue;let r=In(e,a),o=Ln(e,M(e,i),r).get(e,n);t.set(n,o)}J.set(e.parentElement,t)}continue}let ee=!1;if(w&&!C&&d.length>1&&!d.startsWith(`url(`)){let n=M(e),r=parseFloat(n.fontSize)||16,i=parseFloat(n.lineHeight);Number.isFinite(i)||(i=r*1.5),e.getBoundingClientRect().height<i*1.6&&(t.style.whiteSpace=`nowrap`,ee=!0)}let j=document.createElement(`span`);j.dataset.snapdomPseudo=i,j.style.pointerEvents=`none`,ee&&(j.style.whiteSpace=`nowrap`);let te=k(ne(o),`span`);if(n.styleMap.set(j,te),C&&d&&d.length===1){let{dataUrl:e,width:n,height:r}=await Ht(d,h,_,g,v),i=document.createElement(`img`);i.src=e,i.style=`height:${g}px;width:${n/r*g}px;object-fit:contain;`,j.appendChild(i),t.dataset.snapdomHasIcon=`true`}else if(d&&d.startsWith(`url(`)){let t=c(d);if(t?.trim())try{let e=await b(u(t),{as:`dataURL`,useProxy:r.useProxy});if(e?.ok&&typeof e.data==`string`){let t=document.createElement(`img`);t.src=e.data,t.style=`width:${g}px;height:auto;object-fit:contain;`,j.appendChild(t)}}catch(t){console.error(`[snapdom] Error in pseudo ${i} for`,e,t)}}else !C&&w&&(j.textContent=d);j.style.backgroundImage=`none`,`maskImage`in j.style&&(j.style.maskImage=`none`),`webkitMaskImage`in j.style&&(j.style.webkitMaskImage=`none`);try{j.style.backgroundRepeat=o.backgroundRepeat,j.style.backgroundSize=o.backgroundSize,o.backgroundPositionX&&o.backgroundPositionY?(j.style.backgroundPositionX=o.backgroundPositionX,j.style.backgroundPositionY=o.backgroundPositionY):j.style.backgroundPosition=o.backgroundPosition,j.style.backgroundOrigin=o.backgroundOrigin,j.style.backgroundClip=o.backgroundClip,j.style.backgroundAttachment=o.backgroundAttachment,j.style.backgroundBlendMode=o.backgroundBlendMode}catch{}if(E)try{let e=re(p),t=await Promise.all(e.map(T));j.style.backgroundImage=t.join(`, `)}catch(e){console.warn(`[snapdom] Failed to inline background-image for ${i}`,e)}D&&(j.style.backgroundColor=m);let ie=j.childNodes.length>0||j.textContent?.trim()!==``||E||D||O||A;if(f&&f.length&&e.parentElement){let t=J.get(e.parentElement)||new Map,n=In(e,a),r=Ln(e,M(e,i),n);for(let{name:n}of f){if(!n)continue;let i=r.get(e,n);t.set(n,i)}J.set(e.parentElement,t)}if(!ie)continue;i===`::before`?(t.dataset.snapdomHasBefore=`1`,t.insertBefore(j,t.firstChild)):(t.dataset.snapdomHasAfter=`1`,t.appendChild(j))}catch(t){console.warn(`[snapdom] Failed to capture ${i} for`,e,t)}let s=Array.from(t.children).filter(e=>!e.dataset.snapdomPseudo);if(n.nodeMap)for(let e of s){let t=n.nodeMap.get(e);t instanceof Element&&await zn(t,e,n,r)}else{let t=Array.from(e.children);for(let e=0;e<Math.min(t.length,s.length);e++)await zn(t[e],s[e],n,r)}}function Bn(e,t){if(!e||!(e instanceof Element))return;let n=e.ownerDocument||document,r=t||n,i=e instanceof SVGSVGElement?[e]:Array.from(e.querySelectorAll(`svg`));if(i.length===0)return;let a=/url\(\s*#([^)]+)\)/g,o=[`fill`,`stroke`,`filter`,`clip-path`,`mask`,`marker`,`marker-start`,`marker-mid`,`marker-end`],s=e=>window.CSS&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`),c=e=>{if(!e||!e.getAttribute)return null;let t=e.getAttribute(`href`)||e.getAttribute(`xlink:href`)||(typeof e.getAttributeNS==`function`?e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`):null);if(t)return t;let n=e.attributes;if(!n)return null;for(let e=0;e<n.length;e++){let t=n[e];if(!t||!t.name)continue;if(t.name===`href`)return t.value;let r=t.name.indexOf(`:`);if(r!==-1&&t.name.slice(r+1)===`href`)return t.value}return null},l=new Set(Array.from(e.querySelectorAll(`[id]`)).map(e=>e.id)),u=new Set,d=!1,f=(e,t=null)=>{if(!e)return;a.lastIndex=0;let n;for(;n=a.exec(e);){d=!0;let e=(n[1]||``).trim();e&&(l.has(e)||(u.add(e),t&&!t.has(e)&&t.add(e)))}},p=e=>{let t=e.querySelectorAll(`use`);for(let e of t){let t=c(e);if(!t||!t.startsWith(`#`))continue;d=!0;let n=t.slice(1).trim();n&&!l.has(n)&&u.add(n)}let n=e.querySelectorAll(`*[style*="url("],*[fill^="url("], *[stroke^="url("],*[filter^="url("],*[clip-path^="url("],*[mask^="url("],*[marker^="url("],*[marker-start^="url("],*[marker-mid^="url("],*[marker-end^="url("]`);for(let e of n){f(e.getAttribute(`style`)||``);for(let t of o)f(e.getAttribute(t))}};for(let e of i)p(e);if(!d)return;let m=e.querySelector(`svg.inline-defs-container`);m||(m=n.createElementNS(`http://www.w3.org/2000/svg`,`svg`),m.classList.add(`inline-defs-container`),m.setAttribute(`aria-hidden`,`true`),m.setAttribute(`style`,`position:absolute;width:0;height:0;overflow:hidden`),e.insertBefore(m,e.firstChild||null));let h=m.querySelector(`defs`)||null,g=t=>{if(!t||l.has(t))return null;let n=s(t),i=t=>{let n=r.querySelector(t);return n&&!e.contains(n)?n:null};return i(`svg defs > *#${n}`)||i(`svg > symbol#${n}`)||i(`*#${n}`)};if(!u.size)return;let _=new Set(u),v=new Set;for(;_.size;){let e=_.values().next().value;if(_.delete(e),!e||l.has(e)||v.has(e))continue;let t=g(e);if(!t){v.add(e);continue}h||(h=n.createElementNS(`http://www.w3.org/2000/svg`,`defs`),m.appendChild(h));let r=t.cloneNode(!0);r.id||r.setAttribute(`id`,e),h.appendChild(r),v.add(e),l.add(e);let i=[r,...r.querySelectorAll(`*`)];for(let e of i){let t=c(e);if(t&&t.startsWith(`#`)){let e=t.slice(1).trim();e&&!l.has(e)&&!v.has(e)&&_.add(e)}let n=e.getAttribute?.(`style`)||``;n&&f(n,_);for(let t of o){let n=e.getAttribute?.(t);n&&f(n,_)}}}}s();function Vn(e,t){if(!e||!t)return;let n=e.scrollTop||0;if(!n)return;getComputedStyle(t).position===`static`&&(t.style.position=`relative`);let r=e.getBoundingClientRect(),i=e.clientHeight,a=`data-snap-ph`,o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();){let s=o.currentNode,c=getComputedStyle(s),l=c.position;if(l!==`sticky`&&l!==`-webkit-sticky`)continue;let u=Hn(c.top),d=Hn(c.bottom);if(u==null&&d==null)continue;let f=Wn(t,Un(s,e),a);if(!f)continue;let p=s.getBoundingClientRect(),m=p.width,h=p.height,g=p.left-r.left;if(!(m>0&&h>0)||!Number.isFinite(g))continue;let _=u==null?n+(i-h-d):u+n;if(!Number.isFinite(_))continue;let v=Number.parseInt(c.zIndex,10),y=Number.isFinite(v),b=y?Math.max(v,1)+1:2,x=y?v-1:0,S=f.cloneNode(!1);S.setAttribute(a,`1`),S.style.position=`sticky`,S.style.left=`${g}px`,S.style.top=`${_}px`,S.style.width=`${m}px`,S.style.height=`${h}px`,S.style.visibility=`hidden`,S.style.zIndex=String(x),S.style.overflow=`hidden`,S.style.background=`transparent`,S.style.boxShadow=`none`,S.style.filter=`none`,f.parentElement?.insertBefore(S,f),f.style.position=`absolute`,f.style.left=`${g}px`,f.style.top=`${_}px`,f.style.bottom=`auto`,f.style.zIndex=String(b),f.style.pointerEvents=`none`}}function Hn(e){if(!e||e===`auto`)return null;let t=Number.parseFloat(e);return Number.isFinite(t)?t:null}function Un(e,t){let n=[];for(let r=e;r&&r!==t;){let e=r.parentElement;if(!e)break;n.push(Array.prototype.indexOf.call(e.children,r)),r=e}return n.reverse()}function Wn(e,t,n){let r=e;for(let e=0;e<t.length;e++)if(r=Gn(r,n)[t[e]],!r)return null;return r instanceof HTMLElement?r:null}function Gn(e,t){let n=[],r=e.children;for(let e=0;e<r.length;e++){let i=r[e];i.hasAttribute(t)||n.push(i)}return n}function Kn(e){let t=getComputedStyle(e),n=t.outlineStyle,r=t.outlineWidth,i=t.borderStyle,a=t.borderWidth;n!==`none`&&parseFloat(r)>0&&(i===`none`||parseFloat(a)===0)&&(e.style.border=`${r} solid transparent`)}function qn(e){let t=[];try{let n=e.querySelectorAll(`*`);for(let e of n){if(!(e instanceof HTMLElement))continue;let n=e.style.contentVisibility||``,r=getComputedStyle(e),i=r.contentVisibility||r.getPropertyValue(`content-visibility`)||``;(i===`auto`||i===`hidden`)&&(t.push({el:e,original:n}),e.style.contentVisibility=`visible`)}if(e instanceof HTMLElement){let n=getComputedStyle(e),r=n.contentVisibility||n.getPropertyValue(`content-visibility`)||``;(r===`auto`||r===`hidden`)&&(t.push({el:e,original:e.style.contentVisibility||``}),e.style.contentVisibility=`visible`)}}catch{}return()=>{for(let{el:e,original:n}of t)try{e.style.contentVisibility=n}catch{}}}async function Jn(e,t={}){let n={styleMap:o.session.styleMap,styleCache:o.session.styleCache,nodeMap:o.session.nodeMap,options:t},r,i=``,a=``;Kn(e);let s=qn(e);try{Bn(e)}catch(e){console.warn(`inlineExternal defs or symbol failed:`,e)}try{r=await kt(e,n,t)}catch(e){throw console.warn(`deepClone failed:`,e),e}finally{s()}try{await zn(e,r,n,t)}catch(e){console.warn(`inlinePseudoElements failed:`,e)}await Ot(r,n);try{let e=r.querySelectorAll(`style[data-sd]`);for(let t of e)a+=t.textContent||``,t.remove()}catch(e){z(n,`Failed to extract shadow CSS from style[data-sd]`,e)}let c=j(n.styleMap);i=Array.from(c.entries()).map(([e,t])=>`.${t}{${e}}`).join(``),i=a+`[data-snapdom-has-after]::after,[data-snapdom-has-before]::before{content:none!important;display:none!important}`+i;for(let[e,t]of n.styleMap.entries()){if(e.tagName===`STYLE`)continue;if(e.getRootNode&&e.getRootNode()instanceof ShadowRoot){e.setAttribute(`style`,t.replace(/;/g,`; `));continue}let n=c.get(t);n&&e.classList.add(n);let r=e.style?.backgroundImage,i=e.dataset?.snapdomHasIcon;r&&r!==`none`&&(e.style.backgroundImage=r),i&&(e.style.verticalAlign=`middle`,e.style.display=`inline`)}for(let[e,t]of n.nodeMap.entries()){let n=t.scrollLeft,r=t.scrollTop;if((n||r)&&e instanceof HTMLElement){e.style.overflow=`hidden`,e.style.scrollbarWidth=`none`,e.style.msOverflowStyle=`none`;try{let t=e.querySelectorAll(`*`);for(let e of t){if(!(e instanceof HTMLElement))continue;let t=e.style.position;if(t===`fixed`||t===`absolute`){let i=parseFloat(e.style.top)||0,a=parseFloat(e.style.left)||0;e.style.top=`${i+r}px`,e.style.left=`${a+n}px`,t===`fixed`&&(e.style.position=`absolute`)}}}catch{}let t=document.createElement(`div`);for(t.style.transform=`translate(${-n}px, ${-r}px)`,t.style.willChange=`transform`,t.style.display=`inline-block`,t.style.width=`100%`;e.firstChild;)t.appendChild(e.firstChild);e.appendChild(t)}}if(Vn(e,r instanceof HTMLElement&&r.firstElementChild instanceof HTMLElement?r.firstElementChild:r),e===n.nodeMap.get(r)){let t=n.styleCache.get(e)||M(e);n.styleCache.set(e,t);let i=l(t.transform);r.style.margin=`0`,r.style.top=`auto`,r.style.left=`auto`,r.style.right=`auto`,r.style.bottom=`auto`,r.style.animation=`none`,r.style.transition=`none`,r.style.willChange=`auto`,r.style.float=`none`,r.style.clear=`none`,r.style.transform=i||``}for(let[e,t]of n.nodeMap.entries())t.tagName===`PRE`&&(e.style.marginTop=`0`,e.style.marginBlockStart=`0`);return{clone:r,classCSS:i,styleCache:n.styleCache}}w();var Yn=`http://www.w3.org/1999/xlink`;function Xn(e){return e.getAttribute(`href`)||e.getAttribute(`xlink:href`)||(typeof e.getAttributeNS==`function`?e.getAttributeNS(Yn,`href`):null)}function Zn(e){let t=parseInt(e.dataset?.snapdomWidth||``,10)||0,n=parseInt(e.dataset?.snapdomHeight||``,10)||0,r=parseInt(e.getAttribute(`width`)||``,10)||0,i=parseInt(e.getAttribute(`height`)||``,10)||0,a=parseFloat(e.style?.width||``)||0,o=parseFloat(e.style?.height||``)||0;return{width:t||a||r||e.width||e.naturalWidth||100,height:n||o||i||e.height||e.naturalHeight||100}}async function Qn(e,t={}){let n=Array.from(e.querySelectorAll(`img`)),r=async e=>{if(!e.getAttribute(`src`)){let t=e.currentSrc||e.src||``;t&&e.setAttribute(`src`,t)}e.removeAttribute(`srcset`),e.removeAttribute(`sizes`);let n=e.src||``;if(!n)return;let r=await b(n,{as:`dataURL`,useProxy:t.useProxy});if(r.ok&&typeof r.data==`string`&&r.data.startsWith(`data:`)){e.src=r.data,e.width||=e.naturalWidth||100,e.height||=e.naturalHeight||100;return}let{width:i,height:a}=Zn(e),{fallbackURL:o}=t||{};if(o)try{let r=typeof o==`function`?await o({width:i,height:a,src:n,element:e}):o;if(r){let n=await b(r,{as:`dataURL`,useProxy:t.useProxy});if(n?.ok&&typeof n.data==`string`){e.src=n.data,e.width||=i,e.height||=a;return}}}catch{}if(t.placeholders!==!1){let t=document.createElement(`div`);t.style.cssText=[`width:${i}px`,`height:${a}px`,`background:#ccc`,`display:inline-block`,`text-align:center`,`line-height:${a}px`,`color:#666`,`font-size:12px`,`overflow:hidden`].join(`;`),t.textContent=`img`,e.replaceWith(t)}else{let t=document.createElement(`div`);t.style.cssText=`display:inline-block;width:${i}px;height:${a}px;visibility:hidden;`,e.replaceWith(t)}};for(let e=0;e<n.length;e+=6){let t=n.slice(e,e+6).map(r);await Promise.allSettled(t)}let i=Array.from(e.querySelectorAll(`image`)),a=async e=>{let n=Xn(e);if(!n||n.startsWith(`data:`)||n.startsWith(`blob:`))return;let r=await b(n,{as:`dataURL`,useProxy:t.useProxy});r.ok&&typeof r.data==`string`&&r.data.startsWith(`data:`)&&(e.setAttribute(`href`,r.data),e.removeAttribute(`xlink:href`),typeof e.removeAttributeNS==`function`&&e.removeAttributeNS(Yn,`href`))};for(let e=0;e<i.length;e+=6){let t=i.slice(e,e+6).map(a);await Promise.allSettled(t)}}B();async function $n(e,t,n,r={}){let i=[[e,t]],a=[`background-image`,`mask`,`mask-image`,`-webkit-mask`,`-webkit-mask-image`,`mask-source`,`mask-box-image-source`,`mask-border-source`,`-webkit-mask-box-image-source`,`border-image`,`border-image-source`],o=[`mask-position`,`mask-size`,`mask-repeat`,`mask-mode`,`mask-composite`,`-webkit-mask-position`,`-webkit-mask-size`,`-webkit-mask-repeat`,`-webkit-mask-composite`,`mask-origin`,`mask-clip`,`-webkit-mask-origin`,`-webkit-mask-clip`,`-webkit-mask-position-x`,`-webkit-mask-position-y`],s=[`background-position`,`background-position-x`,`background-position-y`,`background-size`,`background-repeat`,`background-origin`,`background-clip`,`background-attachment`,`background-blend-mode`],c=[`border-image-slice`,`border-image-width`,`border-image-outset`,`border-image-repeat`];for(;i.length;){let[e,t]=i.shift();if(!t)continue;let l=n.get(e)||M(e);n.has(e)||n.set(e,l);let u=(()=>{let e=l.getPropertyValue(`border-image`),t=l.getPropertyValue(`border-image-source`);return e&&e!==`none`||t&&t!==`none`})();for(let e of s){let n=l.getPropertyValue(e);n&&t.style.setProperty(e,n)}for(let e of a){let n=l.getPropertyValue(e);if(e===`background-image`&&(!n||n===`none`)){let e=l.getPropertyValue(`background`);e&&/url\s*\(/.test(e)&&(n=re(e).filter(e=>/url\s*\(/.test(e)).join(`, `)||n)}if(!n||n===`none`)continue;let i=re(n),a=await Promise.all(i.map(e=>T(e,r)));a.some(e=>e&&e!==`none`&&!/^url\(undefined/.test(e))&&t.style.setProperty(e,a.join(`, `))}for(let e of o){let n=l.getPropertyValue(e);!n||n===`initial`||t.style.setProperty(e,n)}if(u)for(let e of c){let n=l.getPropertyValue(e);!n||n===`initial`||t.style.setProperty(e,n)}let d=e.shadowRoot?Array.from(e.shadowRoot.children).filter(e=>e.tagName!==`STYLE`):Array.from(e.children),f=Array.from(t.children).filter(e=>!(e.dataset?.snapdomPseudo||e.tagName===`STYLE`&&e.dataset?.sd));for(let e=0;e<Math.min(d.length,f.length);e++)i.push([d[e],f[e]])}}B(),s();function er(e){if(!e)return()=>{};let t=[];function n(e){let r=tr(e);r&&t.push(r);for(let t of e.children||[])n(t)}return n(e),()=>t.forEach(e=>e())}function tr(e){if(!e)return()=>{};let t=nr(e);if(t<=0||!ar(e))return()=>{};let n=getComputedStyle(e),r=Math.round(rr(n)*t+ir(n)),i=e.textContent??``,a=i;if(e.scrollHeight<=r+.5)return()=>{};let o=0,s=i.length,c=-1;for(;o<=s;){let t=o+s>>1;e.textContent=i.slice(0,t)+`…`,e.scrollHeight<=r+.5?(c=t,o=t+1):s=t-1}return e.textContent=(c>=0?i.slice(0,c):``)+`…`,()=>{e.textContent=a}}function nr(e){let t=getComputedStyle(e),n=t.getPropertyValue(`-webkit-line-clamp`)||t.getPropertyValue(`line-clamp`);n=(n||``).trim();let r=parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function rr(e){let t=(e.lineHeight||``).trim(),n=parseFloat(e.fontSize)||16;return!t||t===`normal`?Math.round(n*1.2):t.endsWith(`px`)?parseFloat(t):/^\d+(\.\d+)?$/.test(t)?Math.round(parseFloat(t)*n):t.endsWith(`%`)?Math.round(parseFloat(t)/100*n):Math.round(n*1.2)}function ir(e){return(parseFloat(e.paddingTop)||0)+(parseFloat(e.paddingBottom)||0)}function ar(e){return e.childElementCount>0?!1:Array.from(e.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}var Y=[];function or(e){if(!e)return null;if(Array.isArray(e)){let[t,n]=e;return typeof t==`function`?t(n):t}if(typeof e==`object`&&`plugin`in e){let{plugin:t,options:n}=e;return typeof t==`function`?t(n):t}return typeof e==`function`?e():e}function sr(...e){let t=e.flat();for(let e of t){let t=or(e);t&&(Y.some(e=>e&&e.name&&t.name&&e.name===t.name)||Y.push(t))}}function cr(e){return(e&&Array.isArray(e.plugins)?e.plugins:Y)||Y}async function X(e,t,n){let r=n,i=cr(t);for(let n of i){let i=n&&typeof n[e]==`function`?n[e]:null;if(!i)continue;let a=await i(t,r);typeof a<`u`&&(r=a)}return r}async function lr(e,t,n){let r=[],i=cr(t);for(let a of i){let i=a&&typeof a[e]==`function`?a[e]:null;if(!i)continue;let o=await i(t,n);typeof o<`u`&&r.push(o)}return r}function ur(e){let t=[];if(Array.isArray(e))for(let n of e){let e=or(n);if(!e||!e.name)continue;let r=t.findIndex(t=>t&&t.name===e.name);r>=0&&t.splice(r,1),t.push(e)}for(let e of Y)e&&e.name&&!t.some(t=>t.name===e.name)&&t.push(e);return Object.freeze(t)}function dr(e,t,n=!1){return!e||e.plugins&&!n||(e.plugins=ur(t)),e}function fr(){return Y.slice()}function Z(e){return!!(!e||e.startsWith(`data:`)||e.startsWith(`blob:`)||/^data:image\/(gif|png|svg)/.test(e)&&e.length<200)}function pr(e,t){return!e||!(e instanceof Element)?!1:e.querySelector(`picture`)?!0:t?!!e.querySelector(`img[data-src], img[data-lazy-src], img[data-original], img[data-hi-res-src], img[data-srcset], img[data-lazy-srcset]`):!1}function mr(e,t){let n=e.currentSrc||``;if(n&&!Z(n))return n;let r=t.querySelectorAll(`source[srcset]`),i=null;for(let e of r){let t=e.getAttribute(`srcset`);if(!t||Z(t))continue;let n=e.getAttribute(`media`);if(n)try{if(window.matchMedia(n).matches)return t.split(`,`)[0].trim().split(/\s+/)[0]}catch{}i||=t.split(`,`)[0].trim().split(/\s+/)[0]}return i}function hr(e){let t=[e.getAttribute(`data-src`),e.getAttribute(`data-lazy-src`),e.getAttribute(`data-original`),e.getAttribute(`data-hi-res-src`)];for(let e of t)if(e&&!Z(e))return e;let n=e.getAttribute(`data-srcset`)||e.getAttribute(`data-lazy-srcset`);if(n){let e=n.split(`,`)[0].trim().split(/\s+/)[0];if(e&&!Z(e))return e}return null}function gr(e={}){let t=e.pictureResolver&&typeof e.pictureResolver==`object`?e.pictureResolver:{};return{timeout:t.timeout??5e3,concurrency:t.concurrency??4,resolveLazySrc:t.resolveLazySrc!==!1,silent:t.silent??!1,useProxy:typeof e.useProxy==`string`?e.useProxy:``}}async function _r(e,t={}){if(!e||!(e instanceof Element)||t.resolvePicturePlaceholders===!1)return null;let{timeout:n,concurrency:r,resolveLazySrc:i,silent:a,useProxy:o}=gr(t);if(!pr(e,i))return null;let s=[],c=[];async function l(e){let t=new AbortController,r=setTimeout(()=>t.abort(),n);try{let n=await fetch(e,{credentials:`include`,signal:t.signal});if(!n.ok&&o){let r=o.includes(`{url}`)?o.replace(`{url}`,encodeURIComponent(e)):o.endsWith(`?`)?`${o}${encodeURIComponent(e)}`:`${o}${o.includes(`?`)?`&`:`?`}url=${encodeURIComponent(e)}`;n=await fetch(r,{signal:t.signal})}if(!n.ok)return null;let r=await n.blob();return await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)})}catch{return null}finally{clearTimeout(r)}}async function u(e){for(let t=0;t<e.length;t+=r){let n=e.slice(t,t+r);await Promise.allSettled(n.map(e=>e()))}}let d=e.querySelectorAll(`picture`);for(let e of d){let t=e.querySelector(`img`);if(!t||!Z(t.getAttribute(`src`)||``))continue;let n=mr(t,e);n&&c.push(async()=>{let r=await l(n);if(!r){a||console.warn(`[snapdom:picture-resolver] Failed to fetch: ${n.slice(0,60)}`);return}let i=t.getAttribute(`src`),o=t.getAttribute(`srcset`),c=t.getAttribute(`sizes`),u=[];t.src=r,t.setAttribute(`src`,r),t.removeAttribute(`srcset`),t.removeAttribute(`sizes`);let d=e.querySelectorAll(`source`);for(let e of d)u.push({el:e,parent:e.parentElement,next:e.nextSibling}),e.remove();s.push(()=>{i===null?t.removeAttribute(`src`):t.setAttribute(`src`,i),o!==null&&t.setAttribute(`srcset`,o),c!==null&&t.setAttribute(`sizes`,c);for(let{el:e,parent:t,next:n}of u)t&&t.insertBefore(e,n)})})}if(i){let t=e.querySelectorAll(`img`);for(let e of t){if(e.closest(`picture`)&&Z(e.getAttribute(`src`)||``))continue;let t=e.getAttribute(`src`)||``,n=hr(e);n&&Z(t)&&c.push(async()=>{let t=await l(n);if(!t)return;let r=e.getAttribute(`src`);e.src=t,e.setAttribute(`src`,t),e.removeAttribute(`srcset`),e.removeAttribute(`sizes`),s.push(()=>{r===null?e.removeAttribute(`src`):e.setAttribute(`src`,r)})})}}return c.length===0?null:(await u(c),async function(){for(let e of s)try{e()}catch{}})}B();function vr(e,t,n={}){if(!e||!t||!t.style)return;let r=getComputedStyle(e);try{t.style.boxShadow=`none`}catch(e){z(n,`stripRootShadows boxShadow`,e)}try{t.style.textShadow=`none`}catch(e){z(n,`stripRootShadows textShadow`,e)}try{t.style.outline=`none`}catch(e){z(n,`stripRootShadows outline`,e)}let i=(r.filter||``).replace(/\bblur\([^()]*\)\s*/gi,``).replace(/\bdrop-shadow\([^()]*\)\s*/gi,``).trim().replace(/\s+/g,` `);try{t.style.filter=i.length?i:`none`}catch(e){z(n,`stripRootShadows filter`,e)}}function yr(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),n=[];for(;t.nextNode();)n.push(t.currentNode);for(let e of n)e.remove()}function br(e,t={}){let{stripFrameworkDirectives:n=!0}=t,r=new Set([`xml`,`xlink`]),i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;i.nextNode();){let e=i.currentNode;for(let t of Array.from(e.attributes)){let i=t.name;if(i.includes(`@`)){e.removeAttribute(i);continue}if(i.includes(`:`)){let t=i.split(`:`,1)[0];if(!r.has(t)){e.removeAttribute(i);continue}}if(n&&(i.startsWith(`x-`)||i.startsWith(`v-`)||i.startsWith(`:`)||i.startsWith(`on:`)||i.startsWith(`bind:`)||i.startsWith(`let:`)||i.startsWith(`class:`))){e.removeAttribute(i);continue}}}}function xr(e,t={}){e&&(br(e,t),yr(e))}function Sr(e){try{let t=e.getAttribute?.(`style`)||``;return/\b(height|width|block-size|inline-size)\s*:/.test(t)}catch{return!1}}function Cr(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLIFrameElement||e instanceof SVGElement||e instanceof HTMLObjectElement||e instanceof HTMLEmbedElement}function wr(e,t){if(!(e instanceof Element)||Sr(e)||Cr(e))return!1;let n=t.position;if(n===`absolute`||n===`fixed`||n===`sticky`)return!1;let r=t.display||``;return!(r.includes(`flex`)||r.includes(`grid`)||r.startsWith(`table`)||t.transform&&t.transform!==`none`)}function Tr(e,t,n=new Map){function r(e,t){if(!(e instanceof Element)||!(t instanceof Element))return;let i=e.childElementCount>t.childElementCount,a=n.get(e)||getComputedStyle(e);if(n.has(e)||n.set(e,a),i&&wr(e,a)){t.style.height||(t.style.height=`auto`),t.style.width||(t.style.width=`auto`),t.style.removeProperty(`block-size`),t.style.removeProperty(`inline-size`),t.style.minHeight||(t.style.minHeight=`0`),t.style.minWidth||(t.style.minWidth=`0`),t.style.maxHeight||(t.style.maxHeight=`none`),t.style.maxWidth||(t.style.maxWidth=`none`);let e=a.overflowY||a.overflowBlock||`visible`,n=a.overflowX||a.overflowInline||`visible`;(e!==`visible`||n!==`visible`)&&(t.style.overflow=`visible`)}let o=Array.from(e.children),s=Array.from(t.children);for(let e=0;e<Math.min(o.length,s.length);e++)r(o[e],s[e])}r(e,t)}function Er(e){let t=getComputedStyle(e);return!(t.display===`none`||t.position===`absolute`||t.position===`fixed`)}function Dr(e,t){if(!(e instanceof Element))return!1;if(e.getAttribute(`data-capture`)===`exclude`&&t?.excludeMode===`remove`)return!0;if(Array.isArray(t?.exclude))for(let n of t.exclude)try{if(e.matches(n))return t.excludeMode===`remove`}catch(e){z(t,`exclude selector match failed`,e)}return!1}function Or(e,t){let n=getComputedStyle(e),r=e.getBoundingClientRect(),i=1/0,a=-1/0,o=!1,s=Array.from(e.children);for(let e of s){if(Dr(e,t)||!Er(e))continue;let n=e.getBoundingClientRect(),s=n.top-r.top,c=n.bottom-r.top;c<=s||(s<i&&(i=s),c>a&&(a=c),o=!0)}let c=o?Math.max(0,a-i):0,l=parseFloat(n.borderTopWidth)||0,u=parseFloat(n.borderBottomWidth)||0,d=parseFloat(n.paddingTop)||0,f=parseFloat(n.paddingBottom)||0;return l+u+d+f+c}var Q=(e,t=3)=>Number.isFinite(e)?Math.round(e*10**t)/10**t:e,kr=/::-webkit-scrollbar(-[a-z]+)?\b/i;function Ar(e,t=new Set){let n=``;if(!e)return n;for(let r=0;r<e.length;r++){let i=e[r];try{if(i.type===CSSRule.IMPORT_RULE&&i.styleSheet){n+=Ar(i.styleSheet.cssRules,t);continue}if(i.type===CSSRule.MEDIA_RULE&&i.cssRules){let e=Ar(i.cssRules,t);e&&(n+=`@media ${i.conditionText}{${e}}`);continue}if(i.type===CSSRule.STYLE_RULE){let e=i.selectorText||``;if(kr.test(e)){let e=i.cssText;e&&!t.has(e)&&(t.add(e),n+=e)}}}catch{}}return n}function jr(e){if(!e||!e.styleSheets)return``;let t=new Set,n=``;for(let r of Array.from(e.styleSheets))try{let e=r.cssRules;e&&(n+=Ar(e,t))}catch{}return n}function Mr(e){let t=e.boxShadow||``;if(!t||t===`none`)return{top:0,right:0,bottom:0,left:0};let n=t.split(/\),(?=(?:[^()]*\([^()]*\))*[^()]*$)/).map(e=>e.trim()),r=0,i=0,a=0,o=0;for(let e of n){let t=e.match(/-?\d+(\.\d+)?px/g)?.map(e=>parseFloat(e))||[];if(t.length<2)continue;let[n,s,c=0,l=0]=t,u=Math.abs(n)+c+l,d=Math.abs(s)+c+l;i=Math.max(i,u+Math.max(n,0)),o=Math.max(o,u+Math.max(-n,0)),a=Math.max(a,d+Math.max(s,0)),r=Math.max(r,d+Math.max(-s,0))}return{top:Math.ceil(r),right:Math.ceil(i),bottom:Math.ceil(a),left:Math.ceil(o)}}function Nr(e){let t=(e.filter||``).match(/blur\(\s*([0-9.]+)px\s*\)/),n=t?Math.ceil(parseFloat(t[1])||0):0;return{top:n,right:n,bottom:n,left:n}}function Pr(e){if((e.outlineStyle||`none`)===`none`)return{top:0,right:0,bottom:0,left:0};let t=Math.ceil(parseFloat(e.outlineWidth||`0`)||0),n=parseFloat(e.outlineOffset||`0`)||0,r=t+Math.max(0,Math.ceil(n));return{top:r,right:r,bottom:r,left:r}}function Fr(e){let t=`${e.filter||``} ${e.webkitFilter||``}`.trim();if(!t||t===`none`)return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};let n=t.match(/drop-shadow\((?:[^()]|\([^()]*\))*\)/gi)||[],r=0,i=0,a=0,o=0,s=!1;for(let e of n){s=!0;let[t=0,n=0,c=0]=e.match(/-?\d+(?:\.\d+)?px/gi)?.map(e=>parseFloat(e))||[],l=Math.abs(t)+c,u=Math.abs(n)+c;i=Math.max(i,l+Math.max(t,0)),o=Math.max(o,l+Math.max(-t,0)),a=Math.max(a,u+Math.max(n,0)),r=Math.max(r,u+Math.max(-n,0))}return{bleed:{top:Q(r),right:Q(i),bottom:Q(a),left:Q(o)},has:s}}function Ir(e,t){if(!e||!t||!t.style)return null;let n=getComputedStyle(e);try{t.style.transformOrigin=`0 0`}catch{}try{`translate`in t.style&&(t.style.translate=`none`),`rotate`in t.style&&(t.style.rotate=`none`)}catch{}let r=n.transform||`none`;if(!r||r===`none`)try{let n=Wr(e);if(n.a===1&&n.b===0&&n.c===0&&n.d===1)return t.style.transform=`none`,{a:1,b:0,c:0,d:1}}catch{}function i(e,t,n,r){let i=Math.sqrt(e*e+t*t)||0,a=0,o=0;if(i>0){let s=e/i,c=t/i;a=s*n+c*r;let l=n-s*a,u=r-c*a;o=Math.sqrt(l*l+u*u)||0,o>0?a/=o:a=0}return{a:i,b:0,c:a*o,d:o}}let a=r.match(/^matrix\(\s*([^)]+)\)$/i);if(a){let e=a[1].split(`,`).map(e=>parseFloat(e.trim()));if(e.length===6&&e.every(Number.isFinite)){let[n,r,a,o]=e,s=i(n,r,a,o);try{t.style.transform=`matrix(${s.a}, ${s.b}, ${s.c}, ${s.d}, 0, 0)`}catch{}return s}}let o=r.match(/^matrix3d\(\s*([^)]+)\)$/i);if(o){let e=o[1].split(`,`).map(e=>parseFloat(e.trim()));if(e.length===16&&e.every(Number.isFinite)){let n=e[0],r=e[1],a=e[4],o=e[5],s=i(n,r,a,o);try{t.style.transform=`matrix(${s.a}, ${s.b}, ${s.c}, ${s.d}, 0, 0)`}catch{}return s}}try{let e=new DOMMatrix(r),n=i(e.a,e.b,e.c,e.d);try{t.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, 0, 0)`}catch{}return n}catch{return null}}function Lr(e,t,n,r,i){let a=n.a,o=n.b,s=n.c,c=n.d,l=n.e||0,u=n.f||0;function d(e,t){let n=e-r,d=t-i,f=a*n+s*d,p=o*n+c*d;return f+=r+l,p+=i+u,[f,p]}let f=[d(0,0),d(e,0),d(0,t),d(e,t)],p=1/0,m=1/0,h=-1/0,g=-1/0;for(let[e,t]of f)e<p&&(p=e),t<m&&(m=t),e>h&&(h=e),t>g&&(g=t);return{minX:p,minY:m,maxX:h,maxY:g,width:h-p,height:g-m}}function Rr(e,t,n){let r=(e.transformOrigin||`0 0`).trim().split(/\s+/),[i,a]=[r[0]||`0`,r[1]||`0`],o=(e,t)=>{let n=e.toLowerCase();return n===`left`||n===`top`?0:n===`center`?t/2:n===`right`||n===`bottom`?t:n.endsWith(`px`)?parseFloat(n)||0:n.endsWith(`%`)?(parseFloat(n)||0)*t/100:/^-?\d+(\.\d+)?$/.test(n)&&parseFloat(n)||0};return{ox:o(i,t),oy:o(a,n)}}function zr(e){let t={rotate:`0deg`,scale:null,translate:null},n=typeof e.computedStyleMap==`function`?e.computedStyleMap():null;if(n){let r=e=>{try{return typeof n.has==`function`&&!n.has(e)||typeof n.get!=`function`?null:n.get(e)}catch{return null}},i=r(`rotate`);if(i)if(i.angle){let e=i.angle;t.rotate=e.unit===`rad`?e.value*180/Math.PI+`deg`:e.value+e.unit}else i.unit?t.rotate=i.unit===`rad`?i.value*180/Math.PI+`deg`:i.value+i.unit:t.rotate=String(i);else{let n=getComputedStyle(e);t.rotate=n.rotate&&n.rotate!==`none`?n.rotate:`0deg`}let a=r(`scale`);if(a){let e=`x`in a&&a.x?.value!=null?a.x.value:Array.isArray(a)?a[0]?.value:Number(a)||1;t.scale=`${e} ${`y`in a&&a.y?.value!=null?a.y.value:Array.isArray(a)?a[1]?.value:e}`}else{let n=getComputedStyle(e);t.scale=n.scale&&n.scale!==`none`?n.scale:null}let o=r(`translate`);if(o){let e=`x`in o&&`value`in o.x?o.x.value:Array.isArray(o)?o[0]?.value:0,n=`y`in o&&`value`in o.y?o.y.value:Array.isArray(o)?o[1]?.value:0;t.translate=`${e}${`x`in o&&o.x?.unit?o.x.unit:`px`} ${n}${`y`in o&&o.y?.unit?o.y.unit:`px`}`}else{let n=getComputedStyle(e);t.translate=n.translate&&n.translate!==`none`?n.translate:null}return t}let r=getComputedStyle(e);return t.rotate=r.rotate&&r.rotate!==`none`?r.rotate:`0deg`,t.scale=r.scale&&r.scale!==`none`?r.scale:null,t.translate=r.translate&&r.translate!==`none`?r.translate:null,t}var Br=null;function Vr(){if(Br)return Br;let e=document.createElement(`div`);return e.id=`snapdom-measure-slot`,e.setAttribute(`aria-hidden`,`true`),Object.assign(e.style,{position:`absolute`,left:`-99999px`,top:`0px`,width:`0px`,height:`0px`,overflow:`hidden`,opacity:`0`,pointerEvents:`none`,contain:`size layout style`}),document.documentElement.appendChild(e),Br=e,e}function Hr(e){let t=Vr(),n=document.createElement(`div`);n.style.transformOrigin=`0 0`,e.baseTransform&&(n.style.transform=e.baseTransform),e.rotate&&(n.style.rotate=e.rotate),e.scale&&(n.style.scale=e.scale),e.translate&&(n.style.translate=e.translate),t.appendChild(n);let r=Wr(n);return t.removeChild(n),r}function Ur(e){let t=getComputedStyle(e),n=t.transform||`none`;if(n!==`none`&&!/^matrix\(\s*1\s*,\s*0\s*,\s*0\s*,\s*1\s*,\s*0\s*,\s*0\s*\)$/i.test(n))return!0;let r=t.rotate&&t.rotate!==`none`&&t.rotate!==`0deg`,i=t.scale&&t.scale!==`none`&&t.scale!==`1`,a=t.translate&&t.translate!==`none`&&t.translate!==`0px 0px`;return!!(r||i||a)}function Wr(e){let t=getComputedStyle(e).transform;if(!t||t===`none`)return new DOMMatrix;try{return new DOMMatrix(t)}catch{return new WebKitCSSMatrix(t)}}function Gr(e){if(Array.isArray(e.plugins)){for(let t of e.plugins)if(or(t)?.name===`picture-resolver`)return!0}return fr().some(e=>e?.name===`picture-resolver`)}async function Kr(e,t){if(!e)throw Error(`Element cannot be null or undefined`);i(t.cache);let n=t.fast,r=t.outerTransforms!==!1,a=!!t.outerShadows,s={element:e,options:t,plugins:t.plugins},c,l,u,d=``,f=``,p,m,h=null;await X(`beforeSnap`,s);let g=null;t.resolvePicturePlaceholders!==!1&&!Gr(t)&&(g=await _r(s.element,s.options)),await X(`beforeClone`,s);let _=er(s.element);try{({clone:c,classCSS:l,styleCache:u}=await Jn(s.element,s.options)),!r&&c&&(h=Ir(s.element,c)),!a&&c&&vr(s.element,c,s.options)}finally{_()}if(s={clone:c,classCSS:l,styleCache:u,...s},await X(`afterClone`,s),g&&await g(),xr(s.clone),s.options?.excludeMode===`remove`)try{Tr(s.element,s.clone,s.styleCache)}catch(e){console.warn(`[snapdom] shrink pass failed:`,e)}try{await Vt(s.clone,s.element)}catch{}await new Promise(e=>{I(async()=>{await Qn(s.clone,s.options),e()},{fast:n})}),await new Promise(e=>{I(async()=>{await $n(s.element,s.clone,s.styleCache,s.options),e()},{fast:n})}),t.embedFonts&&await new Promise(e=>{I(async()=>{let t=yn(s.element),n=bn(s.element);L()&&await xn(new Set(Array.from(t).map(e=>String(e).split(`__`)[0]).filter(Boolean)),1),d=await vn({required:t,usedCodepoints:n,preCached:!1,exclude:s.options.excludeFonts,useProxy:s.options.useProxy,fontStylesheetDomains:s.options.fontStylesheetDomains}),e()},{fast:n})});let v=A(s.clone).sort(),y=v.join(`,`);o.baseStyle.has(y)?f=o.baseStyle.get(y):await new Promise(e=>{I(()=>{f=ee(v),o.baseStyle.set(y,f),e()},{fast:n})});let b=jr(s.element?.ownerDocument||document);s={fontsCSS:d,baseCSS:f,scrollbarCSS:b,...s},await X(`beforeRender`,s),await new Promise(e=>{I(()=>{let n=M(s.element),i=s.element.getBoundingClientRect(),c=Math.max(1,Q(s.element.offsetWidth||parseFloat(n.width)||i.width||1)),l=Math.max(1,Q(s.element.offsetHeight||parseFloat(n.height)||i.height||1)),u=s.element.ownerDocument||document;if(s.element===u.body||s.element===u.documentElement){let e=Math.max(s.element.scrollHeight||0,u.documentElement?.scrollHeight||0,u.body?.scrollHeight||0),t=Math.max(s.element.scrollWidth||0,u.documentElement?.scrollWidth||0,u.body?.scrollWidth||0);e>0&&(l=Math.max(l,Q(e))),t>0&&(c=Math.max(c,Q(t)));try{let e=(s.scrollbarCSS||``).length+(s.baseCSS||``).length+(s.fontsCSS||``).length+(s.classCSS||``).length,t=o.measureHints.get(s.element);if(t&&t.cssLen===e&&t.w0===c)t.csh>0&&(l=Math.max(l,Q(t.csh))),t.csw>0&&(c=Math.max(c,Q(t.csw)));else{let t=u.createElement(`div`);t.style.cssText=`position:absolute!important;left:-9999px!important;top:0!important;width:`+c+`px!important;overflow:visible!important;visibility:hidden!important;`;let n=u.createElement(`style`);n.textContent=(s.scrollbarCSS||``)+s.baseCSS+s.fontsCSS+`svg{overflow:visible;} foreignObject{overflow:visible;}`+s.classCSS,t.appendChild(n),t.appendChild(s.clone.cloneNode(!0)),u.body.appendChild(t);let r=t.scrollHeight,i=t.scrollWidth;u.body.removeChild(t),o.measureHints.set(s.element,{cssLen:e,w0:c,csh:r,csw:i}),r>0&&(l=Math.max(l,Q(r))),i>0&&(c=Math.max(c,Q(i)))}}catch{}}if(s.options?.excludeMode===`remove`){let e=Or(s.element,s.options);Number.isFinite(e)&&e>0&&(l=Math.max(1,Math.min(l,Q(e+1))))}let d=(e,t=NaN)=>{let n=typeof e==`string`?parseFloat(e):e;return Number.isFinite(n)?n:t},f=d(s.options.width),g=d(s.options.height),_=c,v=l,y=Number.isFinite(f),b=Number.isFinite(g),x=l>0?c/l:1;y&&b?(_=Math.max(1,Q(f)),v=Math.max(1,Q(g))):y?(_=Math.max(1,Q(f)),v=Math.max(1,Q(_/(x||1)))):b?(v=Math.max(1,Q(g)),_=Math.max(1,Q(v*(x||1)))):(_=c,v=l);let S=0,C=0,w=c,T=l;if(!r&&h&&Number.isFinite(h.a)){let e={a:h.a,b:h.b||0,c:h.c||0,d:h.d||1,e:0,f:0},t=Lr(c,l,e,0,0);S=Q(t.minX),C=Q(t.minY),w=Q(t.maxX),T=Q(t.maxY)}else if(r&&qr(s.element)){let e=n.transform&&n.transform!==`none`?n.transform:``,t=zr(s.element),r=Hr({baseTransform:e,rotate:t.rotate||`0deg`,scale:t.scale,translate:t.translate}),{ox:i,oy:a}=Rr(n,c,l),o=r.is2D?r:new DOMMatrix(r.toString()),u=Lr(c,l,o,i,a);S=Q(u.minX),C=Q(u.minY),w=Q(u.maxX),T=Q(u.maxY)}let E=Mr(n),D=Nr(n),O=Pr(n),k=Fr(n),A=a?{top:Q(E.top+D.top+O.top+k.bleed.top),right:Q(E.right+D.right+O.right+k.bleed.right),bottom:Q(E.bottom+D.bottom+O.bottom+k.bleed.bottom),left:Q(E.left+D.left+O.left+k.bleed.left)}:{top:0,right:0,bottom:0,left:0};S=Q(S-A.left),C=Q(C-A.top),w=Q(w+A.right),T=Q(T+A.bottom);let ee=Math.max(1,Q(w-S)),j=Math.max(1,Q(T-C)),te=y||b?Q(_/c):1,ne=b||y?Q(v/l):1,re=Math.max(1,Q(ee*te)),ie=Math.max(1,Q(j*ne)),N=`http://www.w3.org/2000/svg`,P=Q((L()&&qr(s.element)?1:0)+(r?0:1)),F=document.createElementNS(N,`foreignObject`),ae=Q(S),oe=Q(C);F.setAttribute(`x`,String(Q(-(ae-P)))),F.setAttribute(`y`,String(Q(-(oe-P)))),F.setAttribute(`width`,String(Q(c+P*2))),F.setAttribute(`height`,String(Q(l+P*2))),F.style.overflow=`visible`;let se=document.createElement(`style`);se.textContent=(s.scrollbarCSS||``)+s.baseCSS+s.fontsCSS+`svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject>div{-webkit-text-size-adjust:100%!important;text-size-adjust:100%!important;}`+s.classCSS,F.appendChild(se);let I=document.createElement(`div`);I.setAttribute(`xmlns`,`http://www.w3.org/1999/xhtml`),I.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${Q(c)}px;height:${Q(l)}px`,I.appendChild(s.clone),F.appendChild(I);let ce=new XMLSerializer().serializeToString(F),le=Q(ee+P*2),R=Q(j+P*2),z=y||b;t.meta={w0:c,h0:l,vbW:le,vbH:R,targetW:_,targetH:v},m=`<svg xmlns="${N}" width="${L()&&z?le:Q(re+P*2)}" height="${L()&&z?R:Q(ie+P*2)}" viewBox="0 0 ${le} ${R}" font-size="${parseFloat(M(u.documentElement)?.fontSize)||16}px">`+ce+`</svg>`,p=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,s={svgString:m,dataURL:p,...s},e()},{fast:n})}),await X(`afterRender`,s);let x=document.getElementById(`snapdom-sandbox`);return x&&x.style.position===`absolute`&&x.remove(),s.dataURL}function qr(e){return Ur(e)}s();function Jr(e={}){let t=e.format??`png`;t===`jpg`&&(t=`jpeg`);let n=r(e.cache);return{debug:e.debug??!1,fast:e.fast??!0,scale:e.scale??1,exclude:e.exclude??[],excludeMode:e.excludeMode??`hide`,filter:e.filter??null,filterMode:e.filterMode??`hide`,placeholders:e.placeholders!==!1,embedFonts:e.embedFonts??!1,iconFonts:Array.isArray(e.iconFonts)?e.iconFonts:e.iconFonts?[e.iconFonts]:[],localFonts:Array.isArray(e.localFonts)?e.localFonts:[],excludeFonts:e.excludeFonts??void 0,fontStylesheetDomains:Array.isArray(e.fontStylesheetDomains)?e.fontStylesheetDomains:[],fallbackURL:e.fallbackURL??void 0,cache:n,useProxy:typeof e.useProxy==`string`?e.useProxy:``,width:e.width??null,height:e.height??null,format:t,type:e.type??`svg`,quality:e.quality??.92,dpr:e.dpr??(window.devicePixelRatio||1),backgroundColor:e.backgroundColor??([`jpeg`,`webp`].includes(t)?`#ffffff`:null),filename:e.filename??`snapDOM`,outerTransforms:e.outerTransforms??!0,outerShadows:e.outerShadows??!1,safariWarmupAttempts:Math.min(3,Math.max(1,(e.safariWarmupAttempts??3)|0)),excludeStyleProps:e.excludeStyleProps??null,resolvePicturePlaceholders:e.resolvePicturePlaceholders!==!1,pictureResolver:e.pictureResolver&&typeof e.pictureResolver==`object`?e.pictureResolver:{}}}R(),ue(),B(),w(),s();function Yr(...e){return sr(...e),$}var $=Object.assign($r,{plugins:Yr}),Xr=Symbol(`snapdom.internal`),Zr=Symbol(`snapdom.internal.silent`),Qr=!1;async function $r(e,t){if(!e)throw Error(`Element cannot be null or undefined`);let n=Jr(t);if(dr(n,t&&t.plugins),L()&&(n.embedFonts===!0||ti(e))){if(n.embedFonts)try{let t=yn(e);await xn(new Set([...t].map(e=>String(e).split(`__`)[0]).filter(Boolean)),1)}catch{}let r=n.safariWarmupAttempts??3;for(let n=0;n<r;n++)try{await ei(e,t)}catch{}}return n.iconFonts&&n.iconFonts.length>0&&Nt(n.iconFonts),n.snap||={toPng:(e,t)=>$.toPng(e,t),toSvg:(e,t)=>$.toSvg(e,t)},$.capture(e,n,Xr)}$.capture=async(e,t,n)=>{if(n!==Xr)throw Error(`[snapdom.capture] is internal. Use snapdom(...) instead.`);let r=await Kr(e,t),i={img:async(e,t)=>{let{toImg:n}=await Promise.resolve().then(()=>(Oe(),Ee));return n(r,{...e,...t||{}})},svg:async(e,t)=>{let{toSvg:n}=await Promise.resolve().then(()=>(Oe(),Ee));return n(r,{...e,...t||{}})},canvas:async(e,t)=>{let{toCanvas:n}=await Promise.resolve().then(()=>(Se(),de));return n(r,{...e,...t||{}})},blob:async(e,t)=>{let{toBlob:n}=await Promise.resolve().then(()=>(je(),ke));return n(r,{...e,...t||{}})},png:async(e,t)=>{let{rasterize:n}=await Promise.resolve().then(()=>(Te(),Ce));return n(r,{...e,...t||{},format:`png`})},jpeg:async(e,t)=>{let{rasterize:n}=await Promise.resolve().then(()=>(Te(),Ce));return n(r,{...e,...t||{},format:`jpeg`})},webp:async(e,t)=>{let{rasterize:n}=await Promise.resolve().then(()=>(Te(),Ce));return n(r,{...e,...t||{},format:`webp`})},download:async(e,t)=>{let{download:n}=await Promise.resolve().then(()=>(Fe(),Me));return n(r,{...e,...t||{}})}},a={};for(let e of[`img`,`svg`,`canvas`,`blob`,`png`,`jpeg`,`webp`])a[e]=async n=>i[e](t,{...n||{},[Zr]:!0});a.jpg=a.jpeg;let o=await lr(`defineExports`,{...t,export:{url:r},exports:a}),s=Object.assign({},...o.filter(e=>e&&typeof e==`object`).reverse()),c={...i,...s};c.jpeg&&!c.jpg&&(c.jpg=(e,t)=>c.jpeg(e,t));function l(e,n){let r={...t,...n||{}};return(e===`jpeg`||e===`jpg`)&&(r.backgroundColor==null||r.backgroundColor===`transparent`)&&(r.backgroundColor=`#ffffff`),r}let u=!1,d=Promise.resolve();async function f(e,n){return d=d.then(async()=>{let i=c[e];if(!i)throw Error(`[snapdom] Unknown export type: ${e}`);let a=l(e,n),o={...t,export:{type:e,options:a,url:r}};await X(`beforeExport`,o);let s=await i(o,a);return await X(`afterExport`,o,s),u||(u=!0,await X(`afterSnap`,t)),s})}let p={url:r,toRaw:()=>r,to:(e,t)=>f(e,t),toImg:e=>f(`img`,e),toSvg:e=>f(`svg`,e),toCanvas:e=>f(`canvas`,e),toBlob:e=>f(`blob`,e),toPng:e=>f(`png`,e),toJpg:e=>f(`jpg`,e),toWebp:e=>f(`webp`,e),download:e=>f(`download`,e)};for(let e of Object.keys(c)){let t=`to`+e.charAt(0).toUpperCase()+e.slice(1);p[t]||(p[t]=t=>f(e,t))}return p},$.toRaw=(e,t)=>$(e,t).then(e=>e.toRaw()),$.toImg=(e,t)=>$(e,t).then(e=>e.toImg()),$.toSvg=(e,t)=>$(e,t).then(e=>e.toSvg()),$.toCanvas=(e,t)=>$(e,t).then(e=>e.toCanvas()),$.toBlob=(e,t)=>$(e,t).then(e=>e.toBlob()),$.toPng=(e,t)=>$(e,{...t,format:`png`}).then(e=>e.toPng()),$.toJpg=(e,t)=>$(e,{...t,format:`jpeg`}).then(e=>e.toJpg()),$.toWebp=(e,t)=>$(e,{...t,format:`webp`}).then(e=>e.toWebp()),$.download=(e,t)=>$(e,t).then(e=>e.download());async function ei(e,t){if(Qr)return;let n={...t,fast:!0,embedFonts:!0,scale:.2},r;try{r=await Kr(e,n)}catch(e){z(t,`safariWarmup pre-capture failed`,e)}await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),r&&await new Promise(e=>{let n=new Image;try{n.decoding=`sync`,n.loading=`eager`}catch(e){z(t,`safariWarmup img hints failed`,e)}n.style.cssText=`position:fixed;left:0px;top:0px;width:10px;height:10px;opacity:0.01;pointer-events:none;`,n.src=r,document.body.appendChild(n),(async()=>{try{typeof n.decode==`function`&&await n.decode()}catch(e){z(t,`safariWarmup img.decode failed`,e)}let r=performance.now();for(;!(n.complete&&n.naturalWidth>0)&&performance.now()-r<900;)await new Promise(e=>setTimeout(e,200));await new Promise(e=>requestAnimationFrame(e));try{let e=document.createElement(`canvas`);e.width=Math.max(1,n.naturalWidth||10),e.height=Math.max(1,n.naturalHeight||10);let t=e.getContext(`2d`);t&&t.drawImage(n,0,0)}catch{}await new Promise(e=>requestAnimationFrame(e));try{n.remove()}catch(e){z(t,`safariWarmup img.remove failed`,e)}e()})()}),e.querySelectorAll(`canvas`).forEach(e=>{try{let t=e.getContext(`2d`,{willReadFrequently:!0});t&&t.getImageData(0,0,1,1)}catch(e){z(t,`safariWarmup canvas poke failed`,e)}}),Qr=!0}function ti(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;t.nextNode();){let e=t.currentNode,n=getComputedStyle(e),r=n.backgroundImage&&n.backgroundImage!==`none`,i=n.maskImage&&n.maskImage!==`none`||n.webkitMaskImage&&n.webkitMaskImage!==`none`;if(r||i||e.tagName===`CANVAS`)return!0}return!1}export{$ as snapdom};