@1urso/generic-editor 0.1.52 → 0.1.53

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.
@@ -18646,16 +18646,21 @@ var camelToKebab = (n) => n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toL
18646
18646
  }
18647
18647
  } catch {}
18648
18648
  else {
18649
- let _ = measureTextHeight(A, n.width, M, j), N = n.height, P = _ - N;
18650
- if (P > 0) {
18651
- let A = n.y + N, j = {
18649
+ let _ = 0, N = /<([a-z]+)([^>]*?)>/i.exec(A);
18650
+ if (N) {
18651
+ let E = N[2], O = /height=["']?(\d+)["']?/i.exec(E), P = /height:\s*(\d+)px/i.exec(E);
18652
+ _ = O ? parseInt(O[1]) : P ? parseInt(P[1]) : measureTextHeight(A, n.width, M, j);
18653
+ } else _ = measureTextHeight(A, n.width, M, j);
18654
+ let P = n.height, z = _ - P;
18655
+ if (z > 0) {
18656
+ let A = n.y + P, j = {
18652
18657
  x: n.x,
18653
18658
  y: n.y,
18654
18659
  width: n.width,
18655
- height: N
18660
+ height: P
18656
18661
  };
18657
18662
  n.height = _, E.forEach((_) => {
18658
- _.id !== n.id && (O(j, _) && (_.height += P), _.y >= A && (_.y += P));
18663
+ _.id !== n.id && (O(j, _) && (_.height += z), _.y >= A && (_.y += z));
18659
18664
  });
18660
18665
  }
18661
18666
  }
@@ -18778,7 +18783,10 @@ var camelToKebab = (n) => n.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toL
18778
18783
  ...A,
18779
18784
  ...j
18780
18785
  };
18781
- if (n.type === "text" || n.type === "text-container") return /* @__PURE__ */ jsx("div", {
18786
+ if (n.type === "text" || n.type === "text-container") return /<[a-z][\s\S]*>/i.test(E) ? /* @__PURE__ */ jsx("div", {
18787
+ style: M,
18788
+ dangerouslySetInnerHTML: { __html: E }
18789
+ }) : /* @__PURE__ */ jsx("div", {
18782
18790
  style: M,
18783
18791
  children: E
18784
18792
  });
@@ -55,8 +55,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${n.do
55
55
  }
56
56
  `),()=>{m.contains(p)&&m.removeChild(p)}},[n]),(0,r.jsx)(kw,{isPresent:n,childRef:s,sizeRef:c,children:t.cloneElement(e,{ref:u})})}var jw=({children:e,initial:n,isPresent:i,onExitComplete:a,custom:o,presenceAffectsLayout:s,mode:c,anchorX:l,root:u})=>{let d=Ly(Mw),f=(0,t.useId)(),p=!0,m=(0,t.useMemo)(()=>(p=!1,{id:f,initial:n,isPresent:i,custom:o,onExitComplete:e=>{d.set(e,!0);for(let e of d.values())if(!e)return;a&&a()},register:e=>(d.set(e,!1),()=>d.delete(e))}),[i,d,a]);return s&&p&&(m={...m}),(0,t.useMemo)(()=>{d.forEach((e,t)=>d.set(t,!1))},[i]),t.useEffect(()=>{!i&&!d.size&&a&&a()},[i]),c===`popLayout`&&(e=(0,r.jsx)(Aw,{isPresent:i,anchorX:l,root:u,children:e})),(0,r.jsx)(By.Provider,{value:m,children:e})};function Mw(){return new Map}function Nw(e=!0){let n=(0,t.useContext)(By);if(n===null)return[!0,null];let{isPresent:r,onExitComplete:i,register:a}=n,o=(0,t.useId)();(0,t.useEffect)(()=>{if(e)return a(o)},[e]);let s=(0,t.useCallback)(()=>e&&i&&i(o),[o,i,e]);return!r&&i?[!1,s]:[!0]}var Pw=e=>e.key||``;function Fw(e){let n=[];return t.Children.forEach(e,e=>{(0,t.isValidElement)(e)&&n.push(e)}),n}var Iw=({children:e,custom:n,initial:i=!0,onExitComplete:a,presenceAffectsLayout:o=!0,mode:s=`sync`,propagate:c=!1,anchorX:l=`left`,root:u})=>{let[d,f]=Nw(c),p=(0,t.useMemo)(()=>Fw(e),[e]),m=c&&!d?[]:p.map(Pw),h=(0,t.useRef)(!0),g=(0,t.useRef)(p),_=Ly(()=>new Map),v=(0,t.useRef)(new Set),[y,b]=(0,t.useState)(p),[x,S]=(0,t.useState)(p);zy(()=>{h.current=!1,g.current=p;for(let e=0;e<x.length;e++){let t=Pw(x[e]);m.includes(t)?(_.delete(t),v.current.delete(t)):_.get(t)!==!0&&_.set(t,!1)}},[x,m.length,m.join(`-`)]);let C=[];if(p!==y){let e=[...p];for(let t=0;t<x.length;t++){let n=x[t],r=Pw(n);m.includes(r)||(e.splice(t,0,n),C.push(n))}return s===`wait`&&C.length&&(e=C),S(Fw(e)),b(p),null}process.env.NODE_ENV!==`production`&&s===`wait`&&x.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);let{forceRender:w}=(0,t.useContext)(Iy);return(0,r.jsx)(r.Fragment,{children:x.map(e=>{let t=Pw(e),y=c&&!d?!1:p===x||m.includes(t);return(0,r.jsx)(jw,{isPresent:y,initial:!h.current||i?void 0:!1,custom:n,presenceAffectsLayout:o,mode:s,root:u,onExitComplete:y?void 0:()=>{if(v.current.has(t))return;if(v.current.add(t),_.has(t))_.set(t,!0);else return;let e=!0;_.forEach(t=>{t||(e=!1)}),e&&(w?.(),S(g.current),c&&f?.(),a&&a())},anchorX:l,children:e},t)})})},Lw=(0,t.createContext)({strict:!1}),Rw={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},zw={};for(let e in Rw)zw[e]={isEnabled:t=>Rw[e].some(e=>!!t[e])};function Bw(e){for(let t in e)zw[t]={...zw[t],...e[t]}}var Vw=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.ignoreStrict.viewport`.split(`.`));function Hw(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Vw.has(e)}function Uw(e){var t=Object.create(null);return function(n){return t[n]===void 0&&(t[n]=e(n)),t[n]}}var Ww=d((()=>{})),Gw=p({default:()=>qw}),Kw,qw,Jw=d((()=>{Ww(),Kw=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,qw=Uw(function(e){return Kw.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91})})),Yw=e=>!Hw(e);function Xw(e){typeof e==`function`&&(Yw=t=>t.startsWith(`on`)?!Hw(t):e(t))}try{Xw((Jw(),g(Gw)).default)}catch{}function Zw(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||(Yw(i)||n===!0&&Hw(i)||!t&&!Hw(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Qw=(0,t.createContext)({});function $w(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function eT(e){return typeof e==`string`||Array.isArray(e)}var tT=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],nT=[`initial`,...tT];function rT(e){return $w(e.animate)||nT.some(t=>eT(e[t]))}function iT(e){return!!(rT(e)||e.variants)}function aT(e,t){if(rT(e)){let{initial:t,animate:n}=e;return{initial:t===!1||eT(t)?t:void 0,animate:eT(n)?n:void 0}}return e.inherit===!1?{}:t}function oT(e){let{initial:n,animate:r}=aT(e,(0,t.useContext)(Qw));return(0,t.useMemo)(()=>({initial:n,animate:r}),[sT(n),sT(r)])}function sT(e){return Array.isArray(e)?e.join(` `):e}function cT(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var lT={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(Y.test(e))e=parseFloat(e);else return e;return`${cT(e,t.target.x)}% ${cT(e,t.target.y)}%`}},uT={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Ox.parse(e);if(i.length>5)return r;let a=Ox.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Z(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},dT={borderRadius:{...lT,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:lT,borderTopRightRadius:lT,borderBottomLeftRadius:lT,borderBottomRightRadius:lT,boxShadow:uT};function fT(e,{layout:t,layoutId:n}){return RS.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!dT[e]||e===`opacity`)}var pT={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},mT=LS.length;function hT(e,t,n){let r=``,i=!0;for(let a=0;a<mT;a++){let o=LS[a],s=e[o];if(s===void 0)continue;let c=!0;if(c=typeof s==`number`?s===(o.startsWith(`scale`)?1:0):parseFloat(s)===0,!c||n){let e=YC(s,VC[o]);if(!c){i=!1;let t=pT[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function gT(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(RS.has(e)){o=!0;continue}else if(Ub(e)){i[e]=n;continue}else{let t=YC(n,VC[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=hT(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}var _T=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function vT(e,t,n){for(let r in t)!Sw(t[r])&&!fT(r,n)&&(e[r]=t[r])}function yT({transformTemplate:e},n){return(0,t.useMemo)(()=>{let t=_T();return gT(t,n,e),Object.assign({},t.vars,t.style)},[n])}function bT(e,t){let n=e.style||{},r={};return vT(r,n,e),Object.assign(r,yT(e,t)),r}function xT(e,t){let n={},r=bT(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var ST={offset:`stroke-dashoffset`,array:`stroke-dasharray`},CT={offset:`strokeDashoffset`,array:`strokeDasharray`};function wT(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?ST:CT;e[a.offset]=Y.transform(-r);let o=Y.transform(t),s=Y.transform(n);e[a.array]=`${o} ${s}`}var TT=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function ET(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(gT(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of TT)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&wT(d,i,a,o,!1)}var DT=()=>({..._T(),attrs:{}}),OT=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function kT(e,n,r,i){let a=(0,t.useMemo)(()=>{let t=DT();return ET(t,n,OT(i),e.transformTemplate,e.style),{...t.attrs,style:{...t.style}}},[n]);if(e.style){let t={};vT(t,e.style,e),a.style={...t,...a.style}}return a}var AT=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function jT(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(AT.indexOf(e)>-1||/[A-Z]/u.test(e))}function MT(e,n,r,{latestValues:i},a,o=!1,s){let c=(s??jT(e)?kT:xT)(n,i,a,e),l=Zw(n,typeof e==`string`,o),u=e===t.Fragment?{}:{...l,...c,ref:r},{children:d}=n,f=(0,t.useMemo)(()=>Sw(d)?d.get():d,[d]);return(0,t.createElement)(e,{...u,children:f})}function NT(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function PT(e,t,n,r){if(typeof t==`function`){let[i,a]=NT(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=NT(r);t=t(n===void 0?e.custom:n,i,a)}return t}function FT(e){return Sw(e)?e.get():e}function IT({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:LT(n,r,i,e),renderState:t()}}function LT(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=FT(a[e]);let{initial:o,animate:s}=e,c=rT(e),l=iT(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!$w(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=PT(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var RT=e=>(n,r)=>{let i=(0,t.useContext)(Qw),a=(0,t.useContext)(By),o=()=>IT(e,n,i,a);return r?o():Ly(o)};function zT(e,t,n){let{style:r}=e,i={};for(let a in r)(Sw(r[a])||t.style&&Sw(t.style[a])||fT(a,e)||n?.getValue(a)?.liveStyle!==void 0)&&(i[a]=r[a]);return i}var BT=RT({scrapeMotionValuesFromProps:zT,createRenderState:_T});function VT(e,t,n){let r=zT(e,t,n);for(let n in e)if(Sw(e[n])||Sw(t[n])){let t=LS.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var HT=RT({scrapeMotionValuesFromProps:VT,createRenderState:DT}),UT=Symbol.for(`motionComponentSymbol`);function WT(e,n,r){let i=(0,t.useRef)(r);(0,t.useInsertionEffect)(()=>{i.current=r});let a=(0,t.useRef)(null);return(0,t.useCallback)(t=>{t&&e.onMount?.(t),n&&(t?n.mount(t):n.unmount());let r=i.current;if(typeof r==`function`)if(t){let e=r(t);typeof e==`function`&&(a.current=e)}else a.current?(a.current(),a.current=null):r(t);else r&&(r.current=t)},[n])}var GT=e=>e.replace(/([a-z])([A-Z])/gu,`$1-$2`).toLowerCase(),KT=`data-`+GT(`framerAppearId`),qT=(0,t.createContext)({});function JT(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function YT(e,n,r,i,a,o){let{visualElement:s}=(0,t.useContext)(Qw),c=(0,t.useContext)(Lw),l=(0,t.useContext)(By),u=(0,t.useContext)(Tw).reducedMotion,d=(0,t.useRef)(null);i||=c.renderer,!d.current&&i&&(d.current=i(e,{visualState:n,parent:s,props:r,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:u,isSVG:o}));let f=d.current,p=(0,t.useContext)(qT);f&&!f.projection&&a&&(f.type===`html`||f.type===`svg`)&&XT(d.current,r,a,p);let m=(0,t.useRef)(!1);(0,t.useInsertionEffect)(()=>{f&&m.current&&f.update(r,l)});let h=r[KT],g=(0,t.useRef)(!!h&&!window.MotionHandoffIsComplete?.(h)&&window.MotionHasOptimisedAnimation?.(h));return zy(()=>{f&&(m.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),f.scheduleRenderMicrotask(),g.current&&f.animationState&&f.animationState.animateChanges())}),(0,t.useEffect)(()=>{f&&(!g.current&&f.animationState&&f.animationState.animateChanges(),g.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(h)}),!1),f.enteringChildren=void 0)}),f}function XT(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutCrossfade:u}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:ZT(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&JT(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:u,layoutScroll:c,layoutRoot:l})}function ZT(e){if(e)return e.options.allowProjection===!1?ZT(e.parent):e.projection}function QT(e,{forwardMotionProps:n=!1,type:i}={},a,o){a&&Bw(a);let s=i?i===`svg`:jT(e),c=s?HT:BT;function l(i,l){let u,d={...(0,t.useContext)(Tw),...i,layoutId:$T(i)},{isStatic:f}=d,p=oT(i),m=c(i,f);if(!f&&Ry){eE(d,a);let t=tE(d);u=t.MeasureLayout,p.visualElement=YT(e,m,d,o,t.ProjectionNode,s)}return(0,r.jsxs)(Qw.Provider,{value:p,children:[u&&p.visualElement?(0,r.jsx)(u,{visualElement:p.visualElement,...d}):null,MT(e,i,WT(m,p.visualElement,l),m,f,n,s)]})}l.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let u=(0,t.forwardRef)(l);return u[UT]=e,u}function $T({layoutId:e}){let n=(0,t.useContext)(Iy).id;return n&&e!==void 0?n+`-`+e:e}function eE(e,n){let r=(0,t.useContext)(Lw).strict;if(process.env.NODE_ENV!==`production`&&n&&r){let t="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Gy(!1,t,`lazy-strict-mode`):Ky(!1,t,`lazy-strict-mode`)}}function tE(e){let{drag:t,layout:n}=zw;if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function nE(e,t){if(typeof Proxy>`u`)return QT;let n=new Map,r=(n,r)=>QT(n,r,e,t);return new Proxy((e,t)=>(process.env.NODE_ENV!==`production`&&sb(!1,`motion() is deprecated. Use motion.create() instead.`),r(e,t)),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,QT(a,void 0,e,t)),n.get(a))})}function rE({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function iE({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function aE(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function oE(e){return e===void 0||e===1}function sE({scale:e,scaleX:t,scaleY:n}){return!oE(e)||!oE(t)||!oE(n)}function cE(e){return sE(e)||lE(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function lE(e){return uE(e.x)||uE(e.y)}function uE(e){return e&&e!==`0%`}function dE(e,t,n){return n+t*(e-n)}function fE(e,t,n,r,i){return i!==void 0&&(e=dE(e,i,r)),dE(e,n,r)+t}function pE(e,t=0,n=1,r,i){e.min=fE(e.min,t,n,r,i),e.max=fE(e.max,t,n,r,i)}function mE(e,{x:t,y:n}){pE(e.x,t.translate,t.scale,t.originPoint),pE(e.y,n.translate,n.scale,n.originPoint)}var hE=.999999999999,gE=1.0000000000001;function _E(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&bE(e,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,mE(e,o)),r&&cE(a.latestValues)&&bE(e,a.latestValues))}t.x<gE&&t.x>hE&&(t.x=1),t.y<gE&&t.y>hE&&(t.y=1)}function vE(e,t){e.min+=t,e.max+=t}function yE(e,t,n,r,i=.5){pE(e,t,n,Z(e.min,e.max,i),r)}function bE(e,t){yE(e.x,t.x,t.scaleX,t.scale,t.originX),yE(e.y,t.y,t.scaleY,t.scale,t.originY)}function xE(e,t){return rE(aE(e.getBoundingClientRect(),t))}function SE(e,t,n){let r=xE(e,n),{scroll:i}=t;return i&&(vE(r.x,i.offset.x),vE(r.y,i.offset.y)),r}var CE=()=>({translate:0,scale:1,origin:0,originPoint:0}),wE=()=>({x:CE(),y:CE()}),TE=()=>({min:0,max:0}),$=()=>({x:TE(),y:TE()}),EE={current:null},DE={current:!1};function OE(){if(DE.current=!0,Ry)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>EE.current=e.matches;e.addEventListener(`change`,t),t()}else EE.current=!1}var kE=new WeakMap;function AE(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Sw(i))e.addValue(r,i);else if(Sw(a))e.addValue(r,tw(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,tw(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var jE=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],ME=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,blockInitialAnimation:i,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=ZS,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Bb.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,J.render(this.render,!1,!0))};let{latestValues:s,renderState:c}=a;this.latestValues=s,this.baseTarget={...s},this.initialValues=t.initial?{...s}:{},this.renderState=c,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.options=o,this.blockInitialAnimation=!!i,this.isControllingVariants=rT(t),this.isVariantNode=iT(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:l,...u}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in u){let t=u[e];s[e]!==void 0&&Sw(t)&&t.set(s[e])}}mount(e){this.current=e,kE.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(DE.current||OE(),this.shouldReduceMotion=EE.current),process.env.NODE_ENV!==`production`&&sb(this.shouldReduceMotion!==!0,`You have Reduced Motion enabled on your device. Animations may not appear as expected.`,`reduced-motion-disabled`),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){for(let e in this.projection&&this.projection.unmount(),Fb(this.notifyUpdate),Fb(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this),this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();let n=RS.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&J.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in zw){let t=zw[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):$()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<jE.length;t++){let n=jE[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=AE(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=tw(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Jy(n)||Xy(n))?n=parseFloat(n):!ww(n)&&Ox.test(t)&&(n=WC(e,t)),this.setBaseTarget(e,Sw(n)?n.get():n)),Sw(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=PT(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!Sw(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new nb),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){nw.render(this.render)}},NE=class extends ME{constructor(){super(...arguments),this.KeyframeResolver=qC}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;Sw(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}};function PE(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function FE(e){return window.getComputedStyle(e)}var IE=class extends NE{constructor(){super(...arguments),this.type=`html`,this.renderInstance=PE}readValueFromInstance(e,t){if(RS.has(t))return this.projection?.isProjecting?NS(t):FS(e,t);{let n=FE(e),r=(Ub(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return xE(e,t)}build(e,t,n){gT(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return zT(e,t,n)}},LE=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]);function RE(e,t,n,r){for(let n in PE(e,t,void 0,r),t.attrs)e.setAttribute(LE.has(n)?n:GT(n),t.attrs[n])}var zE=class extends NE{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=$}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(RS.has(t)){let e=UC(t);return e&&e.default||0}return t=LE.has(t)?t:GT(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return VT(e,t,n)}build(e,t,n){ET(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){RE(e,t,n,r)}mount(e){this.isSVGTag=OT(e.tagName),super.mount(e)}},BE=(e,n)=>n.isSVG??jT(e)?new zE(n):new IE(n,{allowProjection:e!==t.Fragment});function VE(e,t,n){let r=e.getProps();return PT(r,t,n===void 0?r.custom:n,e)}var HE=e=>Array.isArray(e);function UE(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,tw(n))}function WE(e){return HE(e)?e[e.length-1]||0:e}function GE(e,t){let{transitionEnd:n={},transition:r={},...i}=VE(e,t)||{};for(let t in i={...i,...n},i)UE(e,t,WE(i[t]))}function KE(e){return!!(Sw(e)&&e.add)}function qE(e,t){let n=e.getValue(`willChange`);if(KE(n))return n.add(t);if(!n&&qy.WillChange){let n=new qy.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function JE(e){return e.props[KT]}var YE=e=>e!==null;function XE(e,{repeat:t,repeatType:n=`loop`},r){let i=e.filter(YE),a=t&&n!==`loop`&&t%2==1?0:i.length-1;return!a||r===void 0?i[a]:r}var ZE={type:`spring`,stiffness:500,damping:25,restSpeed:10},QE=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),$E={type:`keyframes`,duration:.8},eD={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},tD=(e,{keyframes:t})=>t.length>2?$E:RS.has(e)?e.startsWith(`scale`)?QE(t[1]):ZE:eD;function nD({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:a,repeatType:o,repeatDelay:s,from:c,elapsed:l,...u}){return!!Object.keys(u).length}var rD=(e,t,n,r={},i,a)=>o=>{let s=kC(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=rb(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};nD(s)||Object.assign(u,tD(e,u)),u.duration&&=rb(u.duration),u.repeatDelay&&=rb(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(yC(u),u.delay===0&&(d=!0)),(qy.instantAnimations||qy.skipAnimations)&&(d=!0,yC(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=XE(u.keyframes,s);if(e!==void 0){J.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new CS(u):new wC(u)};function iD({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function aD(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a=e.getDefaultTransition(),transitionEnd:o,...s}=t;r&&(a=r);let c=[],l=i&&e.animationState&&e.animationState.getState()[i];for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||l&&iD(l,t))continue;let o={delay:n,...kC(a||{},t)},u=r.get();if(u!==void 0&&!r.isAnimating&&!Array.isArray(i)&&i===u&&!o.velocity)continue;let d=!1;if(window.MotionHandoffAnimation){let n=JE(e);if(n){let e=window.MotionHandoffAnimation(n,t,J);e!==null&&(o.startTime=e,d=!0)}}qE(e,t),r.start(rD(t,r,i,e.shouldReduceMotion&&AC.has(t)?{type:!1}:o,e,d));let f=r.animation;f&&c.push(f)}return o&&Promise.all(c).then(()=>{J.update(()=>{o&&GE(e,o)})}),c}function oD(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}function sD(e,t,n={}){let r=VE(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(aD(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return cD(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function cD(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(sD(c,t,{...o,delay:n+(typeof r==`function`?0:r)+oD(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function lD(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>sD(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=sD(e,t,n);else{let i=typeof t==`function`?VE(e,t,n.custom):t;r=Promise.all(aD(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}function uD(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var dD=nT.length;function fD(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&fD(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<dD;n++){let r=nT[n],i=e.props[r];(eT(i)||i===!1)&&(t[r]=i)}return t}var pD=[...tT].reverse(),mD=tT.length;function hD(e){return t=>Promise.all(t.map(({animation:t,options:n})=>lD(e,t,n)))}function gD(e){let t=hD(e),n=yD(),r=!0,i=t=>(n,r)=>{let i=VE(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function a(n){t=n(e)}function o(a){let{props:o}=e,s=fD(e.parent)||{},c=[],l=new Set,u={},d=1/0;for(let t=0;t<mD;t++){let f=pD[t],p=n[f],m=o[f]===void 0?s[f]:o[f],h=eT(m),g=f===a?p.isActive:null;g===!1&&(d=t);let _=m===s[f]&&m!==o[f]&&h;if(_&&r&&e.manuallyAnimateOnMount&&(_=!1),p.protectedKeys={...u},!p.isActive&&g===null||!m&&!p.prevProp||$w(m)||typeof m==`boolean`)continue;let v=_D(p.prevProp,m),y=v||f===a&&p.isActive&&!_&&h||t>d&&h,b=!1,x=Array.isArray(m)?m:[m],S=x.reduce(i(f),{});g===!1&&(S={});let{prevResolvedValues:C={}}=p,w={...C,...S},T=t=>{y=!0,l.has(t)&&(b=!0,l.delete(t)),p.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in w){let t=S[e],n=C[e];if(u.hasOwnProperty(e))continue;let r=!1;r=HE(t)&&HE(n)?!uD(t,n):t!==n,r?t==null?l.add(e):T(e):t!==void 0&&l.has(e)?T(e):p.protectedKeys[e]=!0}p.prevProp=m,p.prevResolvedValues=S,p.isActive&&(u={...u,...S}),r&&e.blockInitialAnimation&&(y=!1);let E=_&&v;y&&(!E||b)&&c.push(...x.map(t=>{let n={type:f};if(typeof t==`string`&&r&&!E&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=VE(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=oD(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(l.size){let t={};if(typeof o.initial!=`boolean`){let n=VE(e,Array.isArray(o.initial)?o.initial[0]:o.initial);n&&n.transition&&(t.transition=n.transition)}l.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),c.push({animation:t})}let f=!!c.length;return r&&(o.initial===!1||o.initial===o.animate)&&!e.manuallyAnimateOnMount&&(f=!1),r=!1,f?t(c):Promise.resolve()}function s(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=o(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:o,setActive:s,setAnimateFunction:a,getState:()=>n,reset:()=>{n=yD()}}}function _D(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!uD(t,e):!1}function vD(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function yD(){return{animate:vD(!0),whileInView:vD(),whileHover:vD(),whileTap:vD(),whileDrag:vD(),whileFocus:vD(),exit:vD()}}var bD=class{constructor(e){this.isMounted=!1,this.node=e}update(){}},xD=class extends bD{constructor(e){super(e),e.animationState||=gD(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();$w(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},SD=0,CD={animation:{Feature:xD},exit:{Feature:class extends bD{constructor(){super(...arguments),this.id=SD++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function wD(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function TD(e){return{point:{x:e.pageX,y:e.pageY}}}var ED=e=>t=>dw(t)&&e(t,TD(t));function DD(e,t,n,r){return wD(e,t,ED(n),r)}var OD=1e-4,kD=1-OD,AD=1+OD,jD=.01,MD=0-jD,ND=0+jD;function PD(e){return e.max-e.min}function FD(e,t,n){return Math.abs(e-t)<=n}function ID(e,t,n,r=.5){e.origin=r,e.originPoint=Z(t.min,t.max,e.origin),e.scale=PD(n)/PD(t),e.translate=Z(n.min,n.max,e.origin)-e.originPoint,(e.scale>=kD&&e.scale<=AD||isNaN(e.scale))&&(e.scale=1),(e.translate>=MD&&e.translate<=ND||isNaN(e.translate))&&(e.translate=0)}function LD(e,t,n,r){ID(e.x,t.x,n.x,r?r.originX:void 0),ID(e.y,t.y,n.y,r?r.originY:void 0)}function RD(e,t,n){e.min=n.min+t.min,e.max=e.min+PD(t)}function zD(e,t,n){RD(e.x,t.x,n.x),RD(e.y,t.y,n.y)}function BD(e,t,n){e.min=t.min-n.min,e.max=e.min+PD(t)}function VD(e,t,n){BD(e.x,t.x,n.x),BD(e.y,t.y,n.y)}function HD(e){return[e(`x`),e(`y`)]}var UD=({current:e})=>e?e.ownerDocument.defaultView:null,WD=(e,t)=>Math.abs(e-t);function GD(e,t){let n=WD(e.x,t.x),r=WD(e.y,t.y);return Math.sqrt(n**2+r**2)}var KD=new Set([`auto`,`scroll`]),qD=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let e=XD(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=GD(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Ib;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastMoveEventInfo=JD(t,this.transformPagePoint),J.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=XD(e.type===`pointercancel`?this.lastMoveEventInfo:JD(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!dw(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=JD(TD(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Ib;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,XD(s,this.history)),this.removeListeners=eb(DD(this.contextWindow,`pointermove`,this.handlePointerMove),DD(this.contextWindow,`pointerup`,this.handlePointerUp),DD(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(KD.has(e.overflowX)||KD.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener(`scroll`,this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),J.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Fb(this.updatePoint)}};function JD(e,t){return t?{point:t(e.point)}:e}function YD(e,t){return{x:e.x-t.x,y:e.y-t.y}}function XD({point:e},t){return{point:e,delta:YD(e,QD(t)),offset:YD(e,ZD(t)),velocity:$D(t,.1)}}function ZD(e){return e[0]}function QD(e){return e[e.length-1]}function $D(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=QD(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>rb(t)));)n--;if(!r)return{x:0,y:0};let a=ib(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function eO(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Z(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Z(n,e,r.max):Math.min(e,n)),e}function tO(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function nO(e,{top:t,left:n,bottom:r,right:i}){return{x:tO(e.x,n,i),y:tO(e.y,t,r)}}function rO(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function iO(e,t){return{x:rO(e.x,t.x),y:rO(e.y,t.y)}}function aO(e,t){let n=.5,r=PD(e),i=PD(t);return i>r?n=tb(t.min,t.max-r,e.min):r>i&&(n=tb(e.min,e.max-i,t.min)),Uy(0,1,n)}function oO(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var sO=.35;function cO(e=sO){return e===!1?e=0:e===!0&&(e=sO),{x:lO(e,`left`,`right`),y:lO(e,`top`,`bottom`)}}function lO(e,t,n){return{min:uO(e,t),max:uO(e,n)}}function uO(e,t){return typeof e==`number`?e:e[t]||0}var dO=new WeakMap,fO=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=$(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t?(this.stopAnimation(),this.snapToCursor(TD(e).point)):this.pauseAnimation()},a=(e,t)=>{this.stopAnimation();let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ow(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),HD(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ux.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=PD(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&J.postRender(()=>i(e,t)),qE(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=mO(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&a(e,t)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>HD(e=>this.getAnimationState(e)===`paused`&&this.getAxisMotionValue(e).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new qD(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:UD(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&J.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!pO(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=eO(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&JT(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=nO(n.layoutBox,e):this.constraints=!1,this.elastic=cO(t),r!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&HD(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=oO(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!JT(e))return!1;let n=e.current;Ky(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.",`drag-constraints-ref`);let{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=SE(n,r.root,this.visualElement.getTransformPagePoint()),a=iO(r.layout.layoutBox,i);if(t){let e=t(iE(a));this.hasMutatedConstraints=!!e,e&&(a=rE(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=HD(o=>{if(!pO(o,t,this.currentDirection))return;let c=s&&s[o]||{};a&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return qE(this.visualElement,e),n.start(rD(e,n,0,t,this.visualElement,!1))}stopAnimation(){HD(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){HD(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){HD(t=>{let{drag:n}=this.getProps();if(!pO(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-Z(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!JT(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};HD(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=aO({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),HD(t=>{if(!pO(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Z(i,a,r[t]))})}addListeners(){if(!this.visualElement.current)return;dO.set(this.visualElement,this);let e=this.visualElement.current,t=DD(e,`pointerdown`,e=>{let{drag:t,dragListener:n=!0}=this.getProps();t&&n&&!pw(e.target)&&this.start(e)}),n=()=>{let{dragConstraints:e}=this.getProps();JT(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,i=r.addEventListener(`measure`,n);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),J.read(n);let a=wD(window,`resize`,()=>this.scalePositionWithinConstraints()),o=r.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(HD(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{a(),t(),i(),o&&o()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=sO,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function pO(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function mO(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var hO=class extends bD{constructor(e){super(e),this.removeGroupControls=Qy,this.removeListeners=Qy,this.controls=new fO(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Qy}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners()}},gO=e=>(t,n)=>{e&&J.postRender(()=>e(t,n))},_O=class extends bD{constructor(){super(...arguments),this.removePointerDownListener=Qy}onPointerDown(e){this.session=new qD(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:UD(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:gO(e),onStart:gO(t),onMove:n,onEnd:(e,t)=>{delete this.session,r&&J.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=DD(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},vO={hasAnimatedSinceResize:!0,hasEverUpdated:!1},yO=!1,bO=class extends t.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),yO&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),vO.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,yO=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||J.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),nw.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;yO=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function xO(e){let[n,i]=Nw(),a=(0,t.useContext)(Iy);return(0,r.jsx)(bO,{...e,layoutGroup:a,switchLayoutGroup:(0,t.useContext)(qT),isPresent:n,safeToRemove:i})}function SO(e,t,n){let r=Sw(e)?e:tw(e);return r.start(rD(``,r,t,n)),r.animation}var CO=(e,t)=>e.depth-t.depth,wO=class{constructor(){this.children=[],this.isDirty=!1}add(e){Vy(this.children,e),this.isDirty=!0}remove(e){Hy(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(CO),this.isDirty=!1,this.children.forEach(e)}};function TO(e,t){let n=Bb.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Fb(r),e(a-t))};return J.setup(r,!0),()=>Fb(r)}var EO=[`TopLeft`,`TopRight`,`BottomLeft`,`BottomRight`],DO=EO.length,OO=e=>typeof e==`string`?parseFloat(e):e,kO=e=>typeof e==`number`||Y.test(e);function AO(e,t,n,r,i,a){i?(e.opacity=Z(0,n.opacity??1,MO(r)),e.opacityExit=Z(t.opacity??1,0,NO(r))):a&&(e.opacity=Z(t.opacity??1,n.opacity??1,r));for(let i=0;i<DO;i++){let a=`border${EO[i]}Radius`,o=jO(t,a),s=jO(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||kO(o)===kO(s)?(e[a]=Math.max(Z(OO(o),OO(s),r),0),(ux.test(s)||ux.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Z(t.rotate||0,n.rotate||0,r))}function jO(e,t){return e[t]===void 0?e.borderRadius:e[t]}var MO=PO(0,.5,bb),NO=PO(.5,.95,Qy);function PO(e,t,n){return r=>r<e?0:r>t?1:n(tb(e,t,r))}function FO(e,t){e.min=t.min,e.max=t.max}function IO(e,t){FO(e.x,t.x),FO(e.y,t.y)}function LO(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function RO(e,t,n,r,i){return e-=t,e=dE(e,1/n,r),i!==void 0&&(e=dE(e,1/i,r)),e}function zO(e,t=0,n=1,r=.5,i,a=e,o=e){if(ux.test(t)&&(t=parseFloat(t),t=Z(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Z(a.min,a.max,r);e===a&&(s-=t),e.min=RO(e.min,t,n,s,i),e.max=RO(e.max,t,n,s,i)}function BO(e,t,[n,r,i],a,o){zO(e,t[n],t[r],t[i],t.scale,a,o)}var VO=[`x`,`scaleX`,`originX`],HO=[`y`,`scaleY`,`originY`];function UO(e,t,n,r){BO(e.x,t,VO,n?n.x:void 0,r?r.x:void 0),BO(e.y,t,HO,n?n.y:void 0,r?r.y:void 0)}function WO(e){return e.translate===0&&e.scale===1}function GO(e){return WO(e.x)&&WO(e.y)}function KO(e,t){return e.min===t.min&&e.max===t.max}function qO(e,t){return KO(e.x,t.x)&&KO(e.y,t.y)}function JO(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function YO(e,t){return JO(e.x,t.x)&&JO(e.y,t.y)}function XO(e){return PD(e.x)/PD(e.y)}function ZO(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}var QO=class{constructor(){this.members=[]}add(e){Vy(this.members,e),e.scheduleRender()}remove(e){if(Hy(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){let t=this.members.findIndex(t=>e===t);if(t===0)return!1;let n;for(let e=t;e>=0;e--){let t=this.members[e];if(t.isPresent!==!1){n=t;break}}return n?(this.promote(n),!0):!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,t&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);let{crossfade:r}=e.options;r===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:t,resumingFrom:n}=e;t.onExitComplete&&t.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}};function $O(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,rotateX:i,rotateY:a,skewX:o,skewY:s}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotateX(${i}deg) `),a&&(r+=`rotateY(${a}deg) `),o&&(r+=`skewX(${o}deg) `),s&&(r+=`skewY(${s}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var ek={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},tk=[``,`X`,`Y`,`Z`],nk=1e3,rk=0;function ik(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function ak(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=JE(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,J,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&ak(r)}function ok({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=rk++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,jb.value&&(ek.nodes=ek.calculatedTargetDeltas=ek.calculatedProjections=0),this.nodes.forEach(lk),this.nodes.forEach(gk),this.nodes.forEach(_k),this.nodes.forEach(uk),jb.addProjectionMetrics&&jb.addProjectionMetrics(ek)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new wO)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new nb),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=bw(t)&&!xw(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;J.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=TO(i,250),vO.hasAnimatedSinceResize&&(vO.hasAnimatedSinceResize=!1,this.nodes.forEach(hk)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||wk,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!YO(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...kC(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l)}else t||hk(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Fb(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(vk),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ak(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(fk);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(pk);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(mk),this.nodes.forEach(sk),this.nodes.forEach(ck)):this.nodes.forEach(pk),this.clearAllSnapshots();let e=Bb.now();Ib.delta=Uy(0,1e3/60,e-Ib.timestamp),Ib.timestamp=e,Ib.isProcessing=!0,Lb.update.process(Ib),Lb.preRender.process(Ib),Lb.render.process(Ib),Ib.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,nw.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(dk),this.sharedNodes.forEach(yk)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,J.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){J.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!PD(this.snapshot.measuredBox.x)&&!PD(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=$(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!GO(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||cE(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),Ok(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return $();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Ak))){let{scroll:e}=this.root;e&&(vE(t.x,e.offset.x),vE(t.y,e.offset.y))}return t}removeElementScroll(e){let t=$();if(IO(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&IO(t,e),vE(t.x,i.offset.x),vE(t.y,i.offset.y))}return t}applyTransform(e,t=!1){let n=$();IO(n,e);for(let e=0;e<this.path.length;e++){let r=this.path[e];!t&&r.options.layoutScroll&&r.scroll&&r!==r.root&&bE(n,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),cE(r.latestValues)&&bE(n,r.latestValues)}return cE(this.latestValues)&&bE(n,this.latestValues),n}removeTransform(e){let t=$();IO(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!n.instance||!cE(n.latestValues))continue;sE(n.latestValues)&&n.updateSnapshot();let r=$();IO(r,n.measurePageBox()),UO(t,n.latestValues,n.snapshot?n.snapshot.layoutBox:void 0,r)}return cE(this.latestValues)&&UO(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Ib.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Ib.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=$(),this.targetWithTransforms=$()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),zD(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):IO(this.target,this.layout.layoutBox),mE(this.target,this.targetDelta)):IO(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),jb.value&&ek.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||sE(this.parent.latestValues)||lE(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=$(),this.relativeTargetOrigin=$(),VD(this.relativeTargetOrigin,t,n),IO(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Ib.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;IO(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;_E(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=$());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(LO(this.prevProjectionDelta.x,this.projectionDelta.x),LO(this.prevProjectionDelta.y,this.projectionDelta.y)),LD(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!ZO(this.projectionDelta.x,this.prevProjectionDelta.x)||!ZO(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),jb.value&&ek.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=wE(),this.projectionDelta=wE(),this.projectionDeltaWithTransform=wE()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=wE();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=$(),s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=!!(s&&!l&&this.options.crossfade===!0&&!this.path.some(Ck));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;bk(a.x,e.x,n),bk(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(VD(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Sk(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&qO(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=$(),IO(d,this.relativeTarget)),s&&(this.animationValues=i,AO(i,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Fb(this.pendingAnimation),void 0),this.pendingAnimation=J.update(()=>{vO.hasAnimatedSinceResize=!0,Vb.layout++,this.motionValue||=tw(0),this.currentAnimation=SO(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Vb.layout--},onComplete:()=>{Vb.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(nk),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&kk(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||$();let t=PD(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=PD(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}IO(t,n),bE(t,i),LD(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new QO),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&ik(`z`,e,r,this.animationValues);for(let t=0;t<tk.length;t++)ik(`rotate${tk[t]}`,e,r,this.animationValues),ik(`skew${tk[t]}`,e,r,this.animationValues);for(let t in e.render(),r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=FT(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=FT(t?.pointerEvents)||``),this.hasProjected&&!cE(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=$O(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;for(let t in e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit,dT){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=dT[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?FT(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(fk),this.root.sharedNodes.clear()}}}function sk(e){e.updateLayout()}function ck(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;i===`size`?HD(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=PD(r);r.min=n[e].min,r.max=r.min+i}):kk(i,t.layoutBox,n)&&HD(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=PD(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=wE();LD(o,n,t.layoutBox);let s=wE();a?LD(s,e.applyTransform(r,!0),t.measuredBox):LD(s,n,t.layoutBox);let c=!GO(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=$();VD(o,t.layoutBox,i.layoutBox);let s=$();VD(s,n,a.layoutBox),YO(o,s)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=s,e.relativeTargetOrigin=o,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function lk(e){jb.value&&ek.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function uk(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function dk(e){e.clearSnapshot()}function fk(e){e.clearMeasurements()}function pk(e){e.isLayoutDirty=!1}function mk(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function hk(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function gk(e){e.resolveTargetDelta()}function _k(e){e.calcProjection()}function vk(e){e.resetSkewAndRotation()}function yk(e){e.removeLeadSnapshot()}function bk(e,t,n){e.translate=Z(t.translate,0,n),e.scale=Z(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function xk(e,t,n,r){e.min=Z(t.min,n.min,r),e.max=Z(t.max,n.max,r)}function Sk(e,t,n,r){xk(e.x,t.x,n.x,r),xk(e.y,t.y,n.y,r)}function Ck(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var wk={duration:.45,ease:[.4,0,.1,1]},Tk=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Ek=Tk(`applewebkit/`)&&!Tk(`chrome/`)?Math.round:Qy;function Dk(e){e.min=Ek(e.min),e.max=Ek(e.max)}function Ok(e){Dk(e.x),Dk(e.y)}function kk(e,t,n){return e===`position`||e===`preserve-aspect`&&!FD(XO(t),XO(n),.2)}function Ak(e){return e!==e.root&&e.scroll?.wasRoot}var jk=ok({attachResizeListener:(e,t)=>wD(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Mk={current:void 0},Nk=ok({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Mk.current){let e=new jk({});e.mount(window),e.setOptions({layoutScroll:!0}),Mk.current=e}return Mk.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Pk={pan:{Feature:_O},drag:{Feature:hO,ProjectionNode:Nk,MeasureLayout:xO}};function Fk(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&J.postRender(()=>i(t,TD(t)))}var Ik=class extends bD{mount(){let{current:e}=this.node;e&&(this.unmount=lw(e,(e,t)=>(Fk(this.node,t,`Start`),e=>Fk(this.node,e,`End`))))}unmount(){}},Lk=class extends bD{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=eb(wD(this.node.current,`focus`,()=>this.onFocus()),wD(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Rk(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&J.postRender(()=>i(t,TD(t)))}var zk=class extends bD{mount(){let{current:e}=this.node;e&&(this.unmount=yw(e,(e,t)=>(Rk(this.node,t,`Start`),(e,{success:t})=>Rk(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}},Bk=new WeakMap,Vk=new WeakMap,Hk=e=>{let t=Bk.get(e.target);t&&t(e)},Uk=e=>{e.forEach(Hk)};function Wk({root:e,...t}){let n=e||document;Vk.has(n)||Vk.set(n,{});let r=Vk.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Uk,{root:e,...t})),r[i]}function Gk(e,t,n){let r=Wk(t);return Bk.set(e,n),r.observe(e),()=>{Bk.delete(e),r.unobserve(e)}}var Kk={some:0,all:1},qk=class extends bD{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:Kk[r]};return Gk(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Jk(e,t))&&this.startObserver()}unmount(){}};function Jk({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Yk={inView:{Feature:qk},tap:{Feature:zk},focus:{Feature:Lk},hover:{Feature:Ik}},Xk={layout:{ProjectionNode:Nk,MeasureLayout:xO}},Zk=nE({...CD,...Yk,...Pk,...Xk},BE),Qk=(e,t)=>{if(e.id===t.id)return!1;let n=.1;return e.x>=t.x-n&&e.x+e.width<=t.x+t.width+n&&e.y>=t.y-n&&e.y+e.height<=t.y+t.height+n},$k=(e,t,n,r,i=1.2)=>{if(!e)return 0;let a=document.createElement(`canvas`).getContext(`2d`);if(!a)return 0;a.font=`${r}px ${n}`;let o=e.split(` `),s=``,c=1;for(let e=0;e<o.length;e++){let n=s+o[e]+` `;a.measureText(n).width>t&&e>0?(s=o[e]+` `,c++):s=n}let l=e.split(`
57
57
  `).length-1;return c+=l,Math.ceil(c*r*i)};let eA=(e,t)=>{let n=e.map(e=>({...e})),r=new Map(e.map(e=>[e.id,e])),i=[];n.forEach(e=>{let a=e.type===`text`,o=e.type===`text-container`;if((a||o)&&e.autoGrow){let a=e.content;t&&(a=a.replace(/\{\{(.*?)\}\}/g,(n,r)=>{let i=t[r.trim()];return i==null?n:e.formatting?Vv(i,e.formatting):String(i)}));let s=parseInt(String(e.style?.fontSize||16)),c=String(e.style?.fontFamily||`Arial`);if(o&&e.containerExpansion===`horizontal`){let t=document.createElement(`canvas`).getContext(`2d`);if(t){t.font=`${s}px ${c}`;let n=t.measureText(a),r=Math.ceil(n.width+parseInt(String(e.style?.padding||0))*2);r>e.width&&(e.width=r,e.content=a)}}else{let t=$k(a,e.width,c,s),o=e.height,l=t-o;if(l>0){e.height=t,e.content=a;let s=[],c=r.get(e.id);c&&n.forEach(t=>{if(t.id===e.id)return;let n=r.get(t.id);n&&Qk(c,n)&&s.push(t)});let u=new Set([e.id]);s.forEach(e=>{e.height+=l,u.add(e.id)}),i.push({triggerY:e.y+o,delta:l,ignoreIds:u})}}}}),n.forEach(e=>{let t=r.get(e.id);if(!t)return;let n=0;i.forEach(r=>{r.ignoreIds.has(e.id)||t.y>=r.triggerY-.1&&(n+=r.delta)}),e.y+=n});let a=0;return n.forEach(e=>{let t=e.y+e.height;t>a&&(a=t)}),{elements:n,totalHeight:a}};var tA=e=>{if(!e||e.type===`none`)return{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1}};let t={initial:{},animate:{}};switch(e.type){case`fadeIn`:t.initial={opacity:0},t.animate={opacity:1};break;case`slideInLeft`:t.initial={opacity:0,x:-100},t.animate={opacity:1,x:0};break;case`slideInRight`:t.initial={opacity:0,x:100},t.animate={opacity:1,x:0};break;case`slideInUp`:t.initial={opacity:0,y:100},t.animate={opacity:1,y:0};break;case`slideInDown`:t.initial={opacity:0,y:-100},t.animate={opacity:1,y:0};break;case`zoomIn`:t.initial={opacity:0,scale:.5},t.animate={opacity:1,scale:1};break;case`bounceIn`:t.initial={opacity:0,scale:.3},t.animate={opacity:1,scale:1,transition:{type:`spring`,bounce:.6}};break;case`pulse`:t.animate={scale:[1,1.05,1],transition:{repeat:1/0}};break;default:t.initial={opacity:0,y:20},t.animate={opacity:1,y:0}}return t},nA=({element:e,offsetY:t=0,dataContext:n})=>{let i=e.content;if(n){if(e.type===`text`||e.type===`text-container`)i=i.replace(/\{\{(.*?)\}\}/g,(t,r)=>{let i=n[r.trim()];return i==null?t:e.formatting?Vv(i,e.formatting):String(i)});else if(e.type===`image`)if(e.dataBinding){let t=n[e.dataBinding];t!=null&&(i=String(t))}else i=i.replace(/\{\{(.*?)\}\}/g,(e,t)=>{let r=n[t.trim()];return r==null?e:String(r)})}return(0,r.jsxs)(H,{style:{position:`absolute`,left:0,top:0,width:e.type===`text-container`&&e.autoGrow&&e.containerExpansion===`horizontal`?`max-content`:`${e.width}px`,height:e.autoGrow?`auto`:`${e.height}px`,transform:`translate(${e.x}px, ${e.y+t}px) rotate(${e.rotation||0}deg)`,padding:e.type===`image`||e.type===`text`||e.type===`text-container`?0:`8px`,overflow:e.autoGrow?`visible`:`hidden`,whiteSpace:e.type===`text-container`&&e.autoGrow&&e.containerExpansion===`horizontal`?`nowrap`:e.autoGrow?`pre-wrap`:void 0,wordBreak:e.autoGrow?`break-word`:void 0,...e.style},children:[(e.type===`text`||e.type===`text-container`)&&(0,r.jsx)(V,{style:{width:`100%`,height:`100%`,display:`block`},children:i}),e.type===`image`&&(i?(0,r.jsx)(`img`,{src:i,alt:`Element`,style:{width:`100%`,height:`100%`,objectFit:e.style?.objectFit||`cover`,display:`block`}}):(0,r.jsx)(H,{style:{width:`100%`,height:`100%`,backgroundColor:`#eee`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,r.jsx)(V,{size:`1`,children:`Imagem`})})),e.type===`box`&&(0,r.jsx)(H,{style:{width:`100%`,height:`100%`}}),e.type===`checkbox`&&(0,r.jsx)(H,{style:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,r.jsx)(`input`,{type:`checkbox`,checked:n&&e.dataBinding?n[e.dataBinding]===!0||String(n[e.dataBinding])===`true`:!1,readOnly:!0,style:{width:`100%`,height:`100%`,margin:0}})})]})},rA=({item:e,elements:n,animation:i})=>{let{elements:a,totalHeight:o}=t.default.useMemo(()=>eA(n,e),[n,e]),s=t.default.useMemo(()=>tA(i),[i]);return(0,r.jsx)(Zk.div,{layout:!0,initial:s.initial,animate:s.animate,exit:{opacity:0,scale:.9},transition:{duration:i?.duration||.4,ease:i?.timingFunction||`easeOut`},whileHover:{scale:1.02,transition:{duration:.2}},style:{position:`relative`,height:o,width:`100%`,marginBottom:`20px`,transformOrigin:`center center`},children:a.map(t=>(0,r.jsx)(nA,{element:t,offsetY:0,dataContext:e},t.id))})};let iA=()=>{let{state:e}=vv(),[n,i]=t.default.useState(!1),[a,o]=t.default.useState([]);return t.default.useEffect(()=>{let t;return n&&e.isList?(a.length===0&&o([{id:Date.now(),...e.mockData[0]||{}}]),t=setInterval(()=>{o(t=>{let n=t.length%(e.mockData.length||1),r={...e.mockData.length>0?e.mockData[n]:{id:t.length},id:`${Date.now()}-${t.length}`};return e.listSettings.newestPosition===`top`?[r,...t].slice(0,20):[...t,r].slice(-20)})},1500)):o([]),()=>clearInterval(t)},[n,e.isList,e.listSettings.newestPosition,e.mockData]),(0,r.jsxs)(H,{style:{width:`100%`,height:`100%`,position:`relative`,overflow:`hidden`,backgroundColor:`var(--color-panel-solid)`},children:[e.isList&&(0,r.jsx)(H,{style:{position:`absolute`,bottom:10,right:10,zIndex:100,backgroundColor:`var(--color-surface)`,padding:`4px`,borderRadius:`var(--radius-3)`,boxShadow:`0 2px 10px rgba(0,0,0,0.1)`},children:(0,r.jsxs)(W,{size:`1`,variant:n?`soft`:`solid`,color:n?`red`:`green`,onClick:()=>i(!n),children:[n?(0,r.jsx)(Oe,{}):(0,r.jsx)(ve,{}),n?`Parar Simulação`:`Simular Entrada`]})}),(0,r.jsx)(Ph,{type:`auto`,scrollbars:`vertical`,style:{height:`100%`,width:`100%`},children:(0,r.jsx)(H,{style:{position:`relative`,minHeight:`100%`,width:`100%`},children:(()=>{if(e.elements.length===0)return(0,r.jsx)(U,{align:`center`,justify:`center`,style:{height:`100%`},children:(0,r.jsx)(V,{color:`gray`,children:`Preview vazio`})});if(e.isList){let t=[];if(n)t=a;else{if(t=e.mockData.length>0?e.mockData:Array.from({length:10}).map((e,t)=>({id:t})),e.listSettings.sortProp){let n=e.listSettings.sortProp,r=e.listSettings.sortOrder===`asc`?1:-1;t=[...t].sort((e,t)=>{let i=e[n],a=t[n];return i<a?-1*r:i>a?1*r:0})}e.listSettings.newestPosition===`top`&&(t=[...t].reverse())}return(0,r.jsx)(U,{direction:`column`,justify:e.listSettings.newestPosition===`top`?`start`:`end`,p:`4`,style:{width:`100%`,minHeight:`100%`},children:(0,r.jsx)(Iw,{mode:`popLayout`,initial:!1,children:t.map((t,n)=>(0,r.jsx)(rA,{item:t,elements:e.elements,animation:e.listSettings.entryAnimation},t.id||n))})})}return e.elements.map(t=>(0,r.jsx)(nA,{element:t,dataContext:e.singleMockData},t.id))})()})})]})};var aA=({onOpenSettings:e})=>{let{state:n,selectElement:i,renameElement:a,addToGroup:o,removeFromGroup:s,groupElements:c}=vv(),[l,u]=(0,t.useState)({}),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(null),[h,g]=(0,t.useState)(``),_=n.elements.filter(e=>e.type===`group`),v=new Map;_.forEach(e=>{v.set(e.id,n.elements.filter(t=>t.groupId===e.id))});let y=n.elements.filter(e=>e.type!==`group`&&!e.groupId),b=e=>{u(t=>({...t,[e]:!t[e]}))},x=(t,a=0)=>(0,r.jsx)(H,{style:{borderRadius:6,backgroundColor:n.selectedElementIds.includes(t.id)?`var(--gray-5)`:`var(--gray-3)`,border:n.selectedElementIds.includes(t.id)?`1px solid var(--gray-8)`:`1px solid var(--gray-5)`,cursor:`pointer`,overflow:`hidden`,padding:`6px 8px`,paddingLeft:`${8+a*16}px`},draggable:!0,onDragStart:e=>{e.dataTransfer.setData(`application/x-editor-element`,t.id),e.dataTransfer.effectAllowed=`move`},onDragOver:e=>{e.preventDefault()},onDrop:e=>{let r=e.dataTransfer.getData(`application/x-editor-element`);if(!(!r||r===t.id))if(t.type===`group`)o(r,t.id);else{let e=n.elements.find(e=>e.id===r);if(!e)return;let i=t;!e.groupId&&!i.groupId?c([r,i.id]):!i.groupId&&e.groupId?o(i.id,e.groupId):!e.groupId&&i.groupId&&o(r,i.groupId)}},onClick:n=>{i(t.id,n.shiftKey),e&&e(t.id)},children:(0,r.jsxs)(U,{gap:`2`,align:`center`,style:{width:`100%`,overflow:`hidden`},children:[t.type===`text`&&(0,r.jsx)(Ae,{}),t.type===`image`&&(0,r.jsx)(ge,{}),t.type===`box`&&(0,r.jsx)(j,{}),(0,r.jsx)(V,{truncate:!0,style:{flex:1,textAlign:`left`},children:t.name||(t.type===`text`?t.content.length>20?t.content.substring(0,20)+`...`:t.content:t.type===`image`?`Imagem`:`Container`)}),t.type===`group`&&(0,r.jsx)(W,{variant:`ghost`,color:`gray`,size:`1`,onClick:e=>{e.stopPropagation(),m(t.id),g(t.name||`Grupo`),f(!0)},children:`Renomear`})]})},t.id);return(0,r.jsxs)(U,{direction:`column`,gap:`2`,children:[y.map(e=>x(e,0)),_.map(t=>{let n=l[t.id]===!0,a=v.get(t.id)||[];return(0,r.jsxs)(H,{style:{border:`1px dashed var(--gray-6)`,borderRadius:6,backgroundColor:`var(--gray-3)`},children:[(0,r.jsx)(U,{align:`center`,justify:`between`,style:{padding:`6px 8px`,cursor:`pointer`},onClick:()=>{i(t.id),e&&e(t.id)},onDoubleClick:()=>b(t.id),onDragOver:e=>{e.preventDefault()},onDrop:e=>{let n=e.dataTransfer.getData(`application/x-editor-element`);n&&n!==t.id&&o(n,t.id)},children:(0,r.jsxs)(U,{align:`center`,gap:`2`,children:[(0,r.jsx)(j,{}),(0,r.jsx)(V,{style:{fontWeight:600},children:t.name||`Grupo`}),(0,r.jsx)(Dm,{variant:`soft`,color:`blue`,size:`1`,children:a.length})]})}),!n&&(0,r.jsxs)(U,{direction:`column`,gap:`2`,style:{padding:`6px 8px`},children:[a.map(e=>x(e,1)),a.length===0&&(0,r.jsx)(V,{size:`1`,color:`gray`,children:`Solte elementos aqui para agrupar`})]})]},t.id)}),(0,r.jsx)(H,{style:{marginTop:8,padding:`6px 8px`,border:`1px dashed var(--gray-6)`,borderRadius:6},onDragOver:e=>{e.preventDefault()},onDrop:e=>{let t=e.dataTransfer.getData(`application/x-editor-element`);t&&s(t)},children:(0,r.jsx)(V,{size:`1`,color:`gray`,children:`Soltar aqui para remover do grupo`})}),(0,r.jsx)(Bh,{open:d,onOpenChange:f,children:(0,r.jsxs)(Hh,{style:{maxWidth:420},children:[(0,r.jsx)(Uh,{children:`Renomear Grupo`}),(0,r.jsxs)(U,{direction:`column`,gap:`3`,children:[(0,r.jsx)(G,{value:h,onChange:e=>g(e.target.value),placeholder:`Nome do grupo...`}),(0,r.jsxs)(U,{gap:`3`,justify:`end`,children:[(0,r.jsx)(Gh,{children:(0,r.jsx)(W,{variant:`soft`,color:`gray`,children:`Cancelar`})}),(0,r.jsx)(W,{onClick:()=>{p&&a(p,h),f(!1)},children:`Salvar`})]})]})]})})]})},oA=({layout:e,initialState:n,onSave:i,theme:a=`light`})=>{let[o,s]=(0,t.useState)(!0),[c,l]=(0,t.useState)(!0),[u,d]=(0,t.useState)(null),[f,p]=(0,t.useState)(!1),{addElement:m,loadState:h,state:g,undo:_,redo:v,copy:y,paste:b,removeSelected:x,updateElements:S}=vv(),C=t.default.useRef(null),w=()=>{let e={elements:g.elements,isList:g.isList,mockData:g.mockData,singleMockData:g.singleMockData,listSettings:g.listSettings,canvasHeight:g.canvasHeight,gridSize:g.gridSize},t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`layout-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},T=()=>{C.current?.click()},E=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=e=>{try{let t=e.target?.result;h(JSON.parse(t))}catch(e){console.error(`Failed to import layout`,e),alert(`Erro ao importar layout. Arquivo inválido.`)}},n.readAsText(t),e.target.value=``};t.default.useEffect(()=>{let e=e=>{if(document.activeElement?.tagName===`INPUT`||document.activeElement?.tagName===`TEXTAREA`||document.activeElement?.isContentEditable)return;let t=e.clipboardData?.items;if(t){for(let n=0;n<t.length;n++)if(t[n].type.indexOf(`image`)!==-1){e.preventDefault();let r=t[n].getAsFile();if(r){let e=new FileReader;e.onload=e=>{let t=e.target?.result;m({type:`image`,content:t,width:200,height:200})},e.readAsDataURL(r)}}}};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[m]),t.default.useEffect(()=>{let e=e=>{if(!(document.activeElement?.tagName===`INPUT`||document.activeElement?.tagName===`TEXTAREA`||document.activeElement?.isContentEditable)){if((e.ctrlKey||e.metaKey)&&e.key===`z`)e.shiftKey?(e.preventDefault(),v()):(e.preventDefault(),_());else if((e.ctrlKey||e.metaKey)&&e.key===`y`)e.preventDefault(),v();else if((e.ctrlKey||e.metaKey)&&e.key===`c`)e.preventDefault(),y();else if((e.ctrlKey||e.metaKey)&&e.key===`v`)e.preventDefault(),b();else if(e.key===`Delete`||e.key===`Backspace`)g.selectedElementIds.length>0&&(e.preventDefault(),x());else if([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`].includes(e.key)&&g.selectedElementIds.length>0){e.preventDefault();let t=e.shiftKey?10:1,n=[];g.selectedElementIds.forEach(r=>{let i=g.elements.find(e=>e.id===r);if(i){let a={};e.key===`ArrowUp`&&(a.y=i.y-t),e.key===`ArrowDown`&&(a.y=i.y+t),e.key===`ArrowLeft`&&(a.x=i.x-t),e.key===`ArrowRight`&&(a.x=i.x+t),n.push({id:r,changes:a})}}),n.length>0&&S(n)}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,v,y,b,x,g.selectedElementIds,g.elements,S]),t.default.useEffect(()=>{if(n)try{let e=typeof n==`string`?JSON.parse(n):n;Array.isArray(e)?h({elements:e}):e.elements&&h(e)}catch(e){console.error(`Failed to load initial state`,e)}},[n,h]);let D=e=>{console.log(`Adding element of type: ${e}`),m({type:e,content:`New ${e}`})};return(0,r.jsxs)(vm,{appearance:a,accentColor:`blue`,grayColor:`slate`,radius:`medium`,scaling:`100%`,children:[(0,r.jsxs)(U,{direction:`row`,style:{height:`100vh`,width:`100%`,overflow:`hidden`,backgroundColor:`var(--color-background)`},children:[c&&(0,r.jsxs)(U,{direction:`column`,width:`280px`,style:{borderRight:`1px solid var(--gray-5)`,backgroundColor:`var(--gray-2)`,flexShrink:0,height:`100%`},children:[(0,r.jsx)(H,{p:`4`,style:{borderBottom:`1px solid var(--gray-5)`,backgroundColor:`var(--gray-2)`},children:(0,r.jsx)(U,{direction:`column`,gap:`3`,children:(0,r.jsxs)(H,{children:[(0,r.jsx)(V,{size:`2`,weight:`bold`,mb:`2`,as:`div`,children:`Editor`}),(0,r.jsxs)(qh,{children:[(0,r.jsx)(Jh,{children:(0,r.jsx)(W,{variant:`solid`,color:`green`,size:`3`,style:{width:`100%`,cursor:`pointer`,justifyContent:`center`,marginBottom:`8px`},children:`Adicionar Novo +`})}),(0,r.jsxs)(Xh,{style:{width:`240px`},children:[(0,r.jsx)(Qh,{onSelect:()=>D(`text`),children:`Texto`}),(0,r.jsx)(Qh,{onSelect:()=>D(`image`),children:`Imagem`}),(0,r.jsx)(Qh,{onSelect:()=>D(`box`),children:`Caixa (Container)`}),(0,r.jsx)(Qh,{onSelect:()=>D(`text-container`),children:`Container com Texto`})]})]}),(0,r.jsxs)(W,{variant:`soft`,color:`blue`,style:{width:`100%`,justifyContent:`center`,cursor:`pointer`},onClick:()=>{if(i){let e={elements:g.elements,isList:g.isList,mockData:g.mockData,singleMockData:g.singleMockData,listSettings:g.listSettings,canvasHeight:g.canvasHeight};i(JSON.stringify(e,null,2))}},children:[(0,r.jsx)(Se,{}),` Salvar Alterações`]}),(0,r.jsxs)(U,{gap:`2`,mt:`2`,children:[(0,r.jsxs)(W,{variant:`soft`,color:`gray`,style:{flex:1,cursor:`pointer`,justifyContent:`center`},onClick:w,children:[(0,r.jsx)(ce,{}),` Exportar`]}),(0,r.jsxs)(W,{variant:`soft`,color:`gray`,style:{flex:1,cursor:`pointer`,justifyContent:`center`},onClick:T,children:[(0,r.jsx)(Pe,{}),` Importar`]})]}),(0,r.jsx)(`input`,{type:`file`,ref:C,style:{display:`none`},accept:`.json`,onChange:E}),(0,r.jsx)(H,{mt:`2`,children:(0,r.jsx)(Fy,{})})]})})}),(0,r.jsx)(Ph,{type:`auto`,scrollbars:`vertical`,style:{flex:1},children:(0,r.jsxs)(U,{direction:`column`,gap:`4`,p:`4`,children:[(0,r.jsxs)(H,{children:[(0,r.jsx)(V,{size:`2`,weight:`bold`,mb:`2`,as:`div`,children:`Elementos`}),(0,r.jsx)(aA,{onOpenSettings:e=>{d(e),p(!0)}})]}),(0,r.jsx)(yg,{size:`4`}),(0,r.jsxs)(H,{children:[(0,r.jsx)(V,{size:`2`,weight:`bold`,mb:`2`,as:`div`,children:`Variáveis Disponíveis`}),(0,r.jsx)(V,{size:`1`,color:`gray`,mb:`2`,as:`div`,children:`Clique para copiar ou arraste`}),(0,r.jsxs)(U,{direction:`column`,gap:`2`,children:[e.props.map((e,t)=>(0,r.jsxs)(Dm,{color:`blue`,variant:`soft`,size:`2`,style:{padding:`8px`,justifyContent:`flex-start`,cursor:`grab`},title:`Clique para copiar {{${e.dataName}}}`,draggable:!0,onDragStart:t=>{t.dataTransfer.setData(`application/x-editor-prop`,e.dataName),t.dataTransfer.effectAllowed=`copy`},onClick:()=>{let t=`{{${e.dataName}}}`;navigator.clipboard.writeText(t)},children:[e.name,(0,r.jsx)(V,{color:`gray`,style:{marginLeft:`auto`,fontSize:`10px`},children:`{{${e.dataName}}}`})]},t)),e.props.length===0&&(0,r.jsx)(V,{size:`1`,color:`gray`,style:{fontStyle:`italic`},children:`Nenhuma variável configurada.`})]})]})]})})]}),(0,r.jsxs)(H,{style:{flex:1,position:`relative`,height:`100%`},children:[(0,r.jsx)(H,{style:{position:`absolute`,top:10,left:10,zIndex:10},children:(0,r.jsx)(cg,{size:`2`,variant:`soft`,color:`gray`,onClick:()=>l(!c),title:c?`Ocultar Barra Lateral`:`Mostrar Barra Lateral`,children:c?(0,r.jsx)(ae,{}):(0,r.jsx)(se,{})})}),(0,r.jsx)(U,{style:{position:`absolute`,top:10,right:10,zIndex:10},gap:`2`,children:(0,r.jsx)(cg,{size:`2`,variant:`soft`,color:o?`blue`:`gray`,onClick:()=>s(!o),title:o?`Ocultar Preview`:`Mostrar Preview`,children:o?(0,r.jsx)(fe,{}):(0,r.jsx)(ue,{})})}),(0,r.jsxs)(sv,{orientation:`horizontal`,style:{height:`100%`,width:`100%`},children:[(0,r.jsx)(dv,{defaultSize:50,minSize:20,children:(0,r.jsxs)(H,{style:{height:`100%`,width:`100%`,backgroundColor:`var(--color-background)`,position:`relative`},children:[(0,r.jsx)(H,{style:{position:`absolute`,top:16,left:`50%`,transform:`translateX(-50%)`,zIndex:20},children:(0,r.jsx)(yv,{})}),(0,r.jsx)(Py,{})]})}),o&&(0,r.jsx)(mv,{style:{width:`4px`,backgroundColor:`var(--gray-6)`,cursor:`col-resize`,transition:`background-color 0.2s`}}),o&&(0,r.jsx)(dv,{defaultSize:50,minSize:20,children:(0,r.jsx)(H,{style:{height:`100%`,width:`100%`,backgroundColor:`var(--gray-3)`,borderLeft:`1px solid var(--gray-5)`},children:(0,r.jsx)(iA,{})})})]})]})]}),u&&(0,r.jsx)(Dy,{elementId:u,open:f,onOpenChange:p})]})};let sA=e=>(0,r.jsx)(_v,{isList:e.layout.isList,availableProps:e.layout.props,theme:e.theme,children:(0,r.jsx)(oA,{...e})});var cA=e=>e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,`$1-$2`).toLowerCase(),lA=e=>{let t=/^#([0-9a-fA-F]{8})$/.exec(e);if(!t)return e;let n=t[1];return`rgba(${parseInt(n.slice(0,2),16)}, ${parseInt(n.slice(2,4),16)}, ${parseInt(n.slice(4,6),16)}, ${parseInt(n.slice(6,8),16)/255})`},uA=e=>{if(!e)return``;let t=[`width`,`height`,`top`,`left`,`right`,`bottom`,`fontSize`,`borderRadius`,`padding`,`margin`,`borderWidth`,`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];return Object.entries(e).map(([e,n])=>{if(n==null)return``;let r=cA(e),i=typeof n==`number`&&t.includes(e)?n+`px`:n;return typeof i==`string`&&/^#([0-9a-fA-F]{8})$/.test(i)&&(i=lA(i)),`${r}: ${i}`}).filter(Boolean).join(`; `)},dA=(e,t,n,r,i=1.2)=>{if(!e)return 0;try{let a=document.createElement(`canvas`).getContext(`2d`);if(!a)return 0;a.font=`${r}px ${n}`;let o=String(e).split(` `),s=``,c=1;for(let e=0;e<o.length;e++){let n=s+o[e]+` `;a.measureText(n).width>t&&e>0?(s=o[e]+` `,c++):s=n}let l=String(e).split(`
58
- `).length-1;return c+=l,Math.ceil(c*r*i)}catch{return 0}},fA=(e,t,n)=>{let r=String(e).toLowerCase(),i=String(n).toLowerCase();switch(t){case`equals`:return r===i;case`notEquals`:return r!==i;case`contains`:return r.includes(i);case`greaterThan`:return parseFloat(r)>parseFloat(i);case`lessThan`:return parseFloat(r)<parseFloat(i);case`truthy`:return!!e;case`falsy`:return!e;default:return!1}},pA=(e,t)=>{if(!t||t.type===`text`)return e==null?``:String(e);if(e==null)return``;if(t.type===`boolean`)return String(e)===`true`||e===!0||typeof e==`number`&&e>0?t.trueLabel||`Sim`:t.falseLabel||`Não`;if(t.type===`date`)try{let n=new Date(e);if(isNaN(n.getTime()))return String(e);if(t.dateFormat){let e=n.getDate().toString().padStart(2,`0`),r=(n.getMonth()+1).toString().padStart(2,`0`),i=n.getFullYear(),a=n.getHours().toString().padStart(2,`0`),o=n.getMinutes().toString().padStart(2,`0`),s=n.getSeconds().toString().padStart(2,`0`);return t.dateFormat.replace(`DD`,e).replace(`MM`,r).replace(`YYYY`,String(i)).replace(`HH`,a).replace(`mm`,o).replace(`ss`,s)}return n.toLocaleDateString()}catch{return String(e)}if(t.type===`number`){let n=parseFloat(e);return isNaN(n)?String(e):t.numberFormat===`currency`?(t.currencySymbol||`R$`)+` `+n.toFixed(t.decimalPlaces||2):t.numberFormat===`percent`?n.toFixed(t.decimalPlaces||0)+`%`:n.toFixed(t.decimalPlaces||0)}return String(e)},mA=(e,t)=>{let n=JSON.parse(JSON.stringify(e)),r=(e,t)=>{let n=.1;return e.x>=t.x-n&&e.x+e.width<=t.x+t.width+n&&e.y>=t.y-n&&e.y+e.height<=t.y+t.height+n};n.filter(e=>(e.type===`text`||e.type===`text-container`)&&e.autoGrow).sort((e,t)=>e.y-t.y).forEach(e=>{let i=e.content;i=i.replace(/\{\{(.*?)\}\}/g,(e,n)=>{let r=t[n.trim()];return r==null?e:String(r)});let a=parseInt(String(e.style&&e.style.fontSize||16)),o=String(e.style&&e.style.fontFamily||`Arial`);if(e.type===`text-container`&&e.containerExpansion===`horizontal`)try{let t=document.createElement(`canvas`).getContext(`2d`);if(t){t.font=`${a}px ${o}`;let n=t.measureText(i),r=parseInt(String(e.style&&e.style.padding||0))*2,s=Math.ceil(n.width+r);s>e.width&&(e.width=s)}}catch{}else{let t=dA(i,e.width,o,a),s=e.height,c=t-s;if(c>0){let i=e.y+s,a={x:e.x,y:e.y,width:e.width,height:s};e.height=t,n.forEach(t=>{t.id!==e.id&&(r(a,t)&&(t.height+=c),t.y>=i&&(t.y+=c))})}}});let i=0;return n.forEach(e=>{let t=e.y+e.height;t>i&&(i=t)}),{layoutElements:n,maxY:i}},hA=(e,t,n)=>{let{maxY:r}=mA(e,t);return n?Math.max(r,n):r},gA=(e,t,n=0,r=0)=>{let{layoutElements:i}=mA(e,t);return i.map(e=>{let n=e.content,i=``;if(e.type===`text`||e.type===`text-container`)n=n.replace(/\{\{(.*?)\}\}/g,(n,r)=>{let i=t[r.trim()];return i==null?n:e.formatting?pA(i,e.formatting):String(i)});else if(e.type===`image`)if(e.dataBinding){let r=t[e.dataBinding];i=r==null?n:String(r)}else i=n.replace(/\{\{(.*?)\}\}/g,(e,n)=>{let r=t[n.trim()];return r==null?e:String(r)});let a={};e.conditions&&e.conditions.forEach(e=>{let n=t[e.property];fA(n,e.operator,e.value)&&(a={...a,...e.style})});let o={};e.styleBindings&&Object.entries(e.styleBindings).forEach(([e,n])=>{let r=t[n];r!=null&&(o[e]=String(r))});let s={position:`absolute`,left:e.x,top:e.y+r,width:e.width,height:e.autoGrow?`auto`:e.height,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,overflow:e.autoGrow?`visible`:`hidden`,whiteSpace:e.type===`text-container`&&e.autoGrow&&e.containerExpansion===`horizontal`?`nowrap`:e.autoGrow?`pre-wrap`:void 0,wordBreak:e.autoGrow?`break-word`:void 0,...e.style,...a,...o},c=uA(s);if(e.type===`text`||e.type===`text-container`)return`<div style="${c}">${n}</div>`;if(e.type===`image`){let t=uA({width:`100%`,height:`100%`,objectFit:e.style?.objectFit||`cover`,display:`block`});return`<div style="${c}"><img src="${i}" alt="Element" style="${t}" /></div>`}else if(e.type===`box`)return`<div style="${c}"></div>`;else if(e.type===`checkbox`){let n=!1;if(e.dataBinding){let r=t[e.dataBinding];n=r===!0||String(r)===`true`}return`<div style="${uA({...s,display:`flex`,alignItems:`center`,justifyContent:`center`})}"><input type="checkbox" ${n?`checked`:``} disabled style="width:100%;height:100%;margin:0;" /></div>`}return``}).join(`
59
- `)},_A=({element:e,itemData:t})=>{let n=e.content,i=``;if(e.type===`text`||e.type===`text-container`)n=n.replace(/\{\{(.*?)\}\}/g,(n,r)=>{let i=t[r.trim()];return i==null?n:e.formatting?pA(i,e.formatting):String(i)});else if(e.type===`image`)if(e.dataBinding){let r=t[e.dataBinding];i=r==null?n:String(r)}else i=n.replace(/\{\{(.*?)\}\}/g,(e,n)=>{let r=t[n.trim()];return r==null?e:String(r)});let a={};e.conditions&&e.conditions.forEach(e=>{let n=t[e.property];fA(n,e.operator,e.value)&&(a={...a,...e.style})});let o={};e.styleBindings&&Object.entries(e.styleBindings).forEach(([e,n])=>{let r=t[n];r!=null&&(o[e]=String(r))});let s={position:`absolute`,left:e.x,top:e.y,width:e.width,height:e.autoGrow?`auto`:e.height,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,overflow:e.autoGrow?`visible`:`hidden`,whiteSpace:e.type===`text-container`&&e.autoGrow&&e.containerExpansion===`horizontal`?`nowrap`:e.autoGrow?`pre-wrap`:void 0,wordBreak:e.autoGrow?`break-word`:void 0,...e.style,...a,...o};if(e.type===`text`||e.type===`text-container`)return(0,r.jsx)(`div`,{style:s,children:n});if(e.type===`image`){let t={width:`100%`,height:`100%`,objectFit:e.style?.objectFit||`cover`,display:`block`};return(0,r.jsx)(`div`,{style:s,children:(0,r.jsx)(`img`,{src:i,alt:`Element`,style:t})})}else if(e.type===`box`)return(0,r.jsx)(`div`,{style:s});else if(e.type===`checkbox`){let n=!1;if(e.dataBinding){let r=t[e.dataBinding];n=r===!0||String(r)===`true`}return(0,r.jsx)(`div`,{style:{...s,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,r.jsx)(`input`,{type:`checkbox`,checked:n,disabled:!0,style:{width:`100%`,height:`100%`,margin:0}})})}return null},vA=({elements:e,data:t,options:n})=>{let{isList:i,listSettings:a}=n;if(i&&Array.isArray(t)){let i=[...t];if(a?.sortProp){let e=a.sortProp,t=a.sortOrder===`asc`?1:-1;i.sort((n,r)=>(n[e]<r[e]?-1:1)*t)}a?.newestPosition===`top`&&i.reverse();let o=a?.newestPosition===`top`?`flex-start`:`flex-end`,s=a?.entryAnimation||{type:`slideIn`,duration:.3},c=s.type===`none`?`none`:s.type,l=s.duration+`s`,u=s.timingFunction||`ease-out`,d={display:`flex`,flexDirection:`column`,justifyContent:o,height:a?.containerHeight?a.containerHeight+`px`:`100%`,width:`100%`,overflowY:`auto`,overflowX:`hidden`,boxSizing:`border-box`,padding:`10px`};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`
58
+ `).length-1;return c+=l,Math.ceil(c*r*i)}catch{return 0}},fA=(e,t,n)=>{let r=String(e).toLowerCase(),i=String(n).toLowerCase();switch(t){case`equals`:return r===i;case`notEquals`:return r!==i;case`contains`:return r.includes(i);case`greaterThan`:return parseFloat(r)>parseFloat(i);case`lessThan`:return parseFloat(r)<parseFloat(i);case`truthy`:return!!e;case`falsy`:return!e;default:return!1}},pA=(e,t)=>{if(!t||t.type===`text`)return e==null?``:String(e);if(e==null)return``;if(t.type===`boolean`)return String(e)===`true`||e===!0||typeof e==`number`&&e>0?t.trueLabel||`Sim`:t.falseLabel||`Não`;if(t.type===`date`)try{let n=new Date(e);if(isNaN(n.getTime()))return String(e);if(t.dateFormat){let e=n.getDate().toString().padStart(2,`0`),r=(n.getMonth()+1).toString().padStart(2,`0`),i=n.getFullYear(),a=n.getHours().toString().padStart(2,`0`),o=n.getMinutes().toString().padStart(2,`0`),s=n.getSeconds().toString().padStart(2,`0`);return t.dateFormat.replace(`DD`,e).replace(`MM`,r).replace(`YYYY`,String(i)).replace(`HH`,a).replace(`mm`,o).replace(`ss`,s)}return n.toLocaleDateString()}catch{return String(e)}if(t.type===`number`){let n=parseFloat(e);return isNaN(n)?String(e):t.numberFormat===`currency`?(t.currencySymbol||`R$`)+` `+n.toFixed(t.decimalPlaces||2):t.numberFormat===`percent`?n.toFixed(t.decimalPlaces||0)+`%`:n.toFixed(t.decimalPlaces||0)}return String(e)},mA=(e,t)=>{let n=JSON.parse(JSON.stringify(e)),r=(e,t)=>{let n=.1;return e.x>=t.x-n&&e.x+e.width<=t.x+t.width+n&&e.y>=t.y-n&&e.y+e.height<=t.y+t.height+n};n.filter(e=>(e.type===`text`||e.type===`text-container`)&&e.autoGrow).sort((e,t)=>e.y-t.y).forEach(e=>{let i=e.content;i=i.replace(/\{\{(.*?)\}\}/g,(e,n)=>{let r=t[n.trim()];return r==null?e:String(r)});let a=parseInt(String(e.style&&e.style.fontSize||16)),o=String(e.style&&e.style.fontFamily||`Arial`);if(e.type===`text-container`&&e.containerExpansion===`horizontal`)try{let t=document.createElement(`canvas`).getContext(`2d`);if(t){t.font=`${a}px ${o}`;let n=t.measureText(i),r=parseInt(String(e.style&&e.style.padding||0))*2,s=Math.ceil(n.width+r);s>e.width&&(e.width=s)}}catch{}else{let t=0,s=/<([a-z]+)([^>]*?)>/i.exec(i);if(s){let n=s[2],r=/height=["']?(\d+)["']?/i.exec(n),c=/height:\s*(\d+)px/i.exec(n);t=r?parseInt(r[1]):c?parseInt(c[1]):dA(i,e.width,o,a)}else t=dA(i,e.width,o,a);let c=e.height,l=t-c;if(l>0){let i=e.y+c,a={x:e.x,y:e.y,width:e.width,height:c};e.height=t,n.forEach(t=>{t.id!==e.id&&(r(a,t)&&(t.height+=l),t.y>=i&&(t.y+=l))})}}});let i=0;return n.forEach(e=>{let t=e.y+e.height;t>i&&(i=t)}),{layoutElements:n,maxY:i}},hA=(e,t,n)=>{let{maxY:r}=mA(e,t);return n?Math.max(r,n):r},gA=(e,t,n=0,r=0)=>{let{layoutElements:i}=mA(e,t);return i.map(e=>{let n=e.content,i=``;if(e.type===`text`||e.type===`text-container`)n=n.replace(/\{\{(.*?)\}\}/g,(n,r)=>{let i=t[r.trim()];return i==null?n:e.formatting?pA(i,e.formatting):String(i)});else if(e.type===`image`)if(e.dataBinding){let r=t[e.dataBinding];i=r==null?n:String(r)}else i=n.replace(/\{\{(.*?)\}\}/g,(e,n)=>{let r=t[n.trim()];return r==null?e:String(r)});let a={};e.conditions&&e.conditions.forEach(e=>{let n=t[e.property];fA(n,e.operator,e.value)&&(a={...a,...e.style})});let o={};e.styleBindings&&Object.entries(e.styleBindings).forEach(([e,n])=>{let r=t[n];r!=null&&(o[e]=String(r))});let s={position:`absolute`,left:e.x,top:e.y+r,width:e.width,height:e.autoGrow?`auto`:e.height,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,overflow:e.autoGrow?`visible`:`hidden`,whiteSpace:e.type===`text-container`&&e.autoGrow&&e.containerExpansion===`horizontal`?`nowrap`:e.autoGrow?`pre-wrap`:void 0,wordBreak:e.autoGrow?`break-word`:void 0,...e.style,...a,...o},c=uA(s);if(e.type===`text`||e.type===`text-container`)return`<div style="${c}">${n}</div>`;if(e.type===`image`){let t=uA({width:`100%`,height:`100%`,objectFit:e.style?.objectFit||`cover`,display:`block`});return`<div style="${c}"><img src="${i}" alt="Element" style="${t}" /></div>`}else if(e.type===`box`)return`<div style="${c}"></div>`;else if(e.type===`checkbox`){let n=!1;if(e.dataBinding){let r=t[e.dataBinding];n=r===!0||String(r)===`true`}return`<div style="${uA({...s,display:`flex`,alignItems:`center`,justifyContent:`center`})}"><input type="checkbox" ${n?`checked`:``} disabled style="width:100%;height:100%;margin:0;" /></div>`}return``}).join(`
59
+ `)},_A=({element:e,itemData:t})=>{let n=e.content,i=``;if(e.type===`text`||e.type===`text-container`)n=n.replace(/\{\{(.*?)\}\}/g,(n,r)=>{let i=t[r.trim()];return i==null?n:e.formatting?pA(i,e.formatting):String(i)});else if(e.type===`image`)if(e.dataBinding){let r=t[e.dataBinding];i=r==null?n:String(r)}else i=n.replace(/\{\{(.*?)\}\}/g,(e,n)=>{let r=t[n.trim()];return r==null?e:String(r)});let a={};e.conditions&&e.conditions.forEach(e=>{let n=t[e.property];fA(n,e.operator,e.value)&&(a={...a,...e.style})});let o={};e.styleBindings&&Object.entries(e.styleBindings).forEach(([e,n])=>{let r=t[n];r!=null&&(o[e]=String(r))});let s={position:`absolute`,left:e.x,top:e.y,width:e.width,height:e.autoGrow?`auto`:e.height,transform:e.rotation?`rotate(${e.rotation}deg)`:void 0,overflow:e.autoGrow?`visible`:`hidden`,whiteSpace:e.type===`text-container`&&e.autoGrow&&e.containerExpansion===`horizontal`?`nowrap`:e.autoGrow?`pre-wrap`:void 0,wordBreak:e.autoGrow?`break-word`:void 0,...e.style,...a,...o};if(e.type===`text`||e.type===`text-container`)return/<[a-z][\s\S]*>/i.test(n)?(0,r.jsx)(`div`,{style:s,dangerouslySetInnerHTML:{__html:n}}):(0,r.jsx)(`div`,{style:s,children:n});if(e.type===`image`){let t={width:`100%`,height:`100%`,objectFit:e.style?.objectFit||`cover`,display:`block`};return(0,r.jsx)(`div`,{style:s,children:(0,r.jsx)(`img`,{src:i,alt:`Element`,style:t})})}else if(e.type===`box`)return(0,r.jsx)(`div`,{style:s});else if(e.type===`checkbox`){let n=!1;if(e.dataBinding){let r=t[e.dataBinding];n=r===!0||String(r)===`true`}return(0,r.jsx)(`div`,{style:{...s,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,r.jsx)(`input`,{type:`checkbox`,checked:n,disabled:!0,style:{width:`100%`,height:`100%`,margin:0}})})}return null},vA=({elements:e,data:t,options:n})=>{let{isList:i,listSettings:a}=n;if(i&&Array.isArray(t)){let i=[...t];if(a?.sortProp){let e=a.sortProp,t=a.sortOrder===`asc`?1:-1;i.sort((n,r)=>(n[e]<r[e]?-1:1)*t)}a?.newestPosition===`top`&&i.reverse();let o=a?.newestPosition===`top`?`flex-start`:`flex-end`,s=a?.entryAnimation||{type:`slideIn`,duration:.3},c=s.type===`none`?`none`:s.type,l=s.duration+`s`,u=s.timingFunction||`ease-out`,d={display:`flex`,flexDirection:`column`,justifyContent:o,height:a?.containerHeight?a.containerHeight+`px`:`100%`,width:`100%`,overflowY:`auto`,overflowX:`hidden`,boxSizing:`border-box`,padding:`10px`};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`
60
60
  @keyframes slideIn {
61
61
  from { opacity: 0; transform: translateY(20px); }
62
62
  to { opacity: 1; transform: translateY(0); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1urso/generic-editor",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },