backflow-ui-renderer 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backflow-remote-ui/src/index.d.ts.map +1 -1
- package/dist/index.cjs +14 -14
- package/dist/index.js +1565 -1493
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).filter(x=>x.startsWith("data:")).forEach(x=>ye({type:"sse",url:l,data:wn(x.slice(5).trim()),time:Date.now()}))}}catch{}})()}return a}catch(a){throw ye({type:"network",method:c,url:l,error:(a==null?void 0:a.message)||String(a),requestBody:h,time:Date.now()}),a}};const t=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(i,r,...o){return this.__bfMethod=i,this.__bfUrl=r,t.apply(this,[i,r,...o])},XMLHttpRequest.prototype.send=function(i){return this.addEventListener("loadend",()=>{ye({type:"network",method:this.__bfMethod||"GET",url:this.__bfUrl||"",status:this.status,ok:this.status>=200&&this.status<300,requestBody:typeof i=="string"?wn(i):void 0,responseBody:typeof this.responseText=="string"?wn(this.responseText):void 0,time:Date.now()})}),n.call(this,i)};const s=window.WebSocket;if(window.WebSocket=new Proxy(s,{construct(i,r){const o=new i(...r),l=String(r[0]);o.addEventListener("open",()=>ye({type:"ws",url:l,direction:"open",time:Date.now()})),o.addEventListener("close",()=>ye({type:"ws",url:l,direction:"close",time:Date.now()})),o.addEventListener("error",()=>ye({type:"ws",url:l,direction:"error",time:Date.now()})),o.addEventListener("message",h=>ye({type:"ws",url:l,direction:"receive",data:wn(String(h.data)),time:Date.now()}));const c=o.send.bind(o);return o.send=h=>(ye({type:"ws",url:l,direction:"send",data:wn(String(h)),time:Date.now()}),c(h)),o}}),"EventSource"in window){const i=window.EventSource;window.EventSource=new Proxy(i,{construct(r,o){const l=new r(...o),c=String(o[0]);return l.addEventListener("message",h=>ye({type:"sse",url:c,data:wn(String(h.data)),time:Date.now()})),l.addEventListener("error",()=>ye({type:"ws",url:c,direction:"error",time:Date.now()})),l}})}}function $a(e=!1){const t=[...Is];return e&&(Is=[]),t}function Na(){Is=[]}let kn=null;async function ip(e){var t,n;switch(e.command){case"trigger":return Pa(e.matcher||{});case"fill":return _a(e.matcher||{},e.value??"");case"scroll":return Ou(e.matcher,e.direction,e.amount);case"drag":return!e.sourceMatcher||!e.targetMatcher?!1:Uu(e.sourceMatcher,e.targetMatcher);case"getDom":return Hu(e.matcher,e.maxChars);case"evaluate":return qu(e.script??"");case"diagnostics":{const s=window.__backflowDiagnostics;return s?e.submit?(t=s.sendReport)==null?void 0:t.call(s):(n=s.getReport)==null?void 0:n.call(s):{error:"UI diagnostics unavailable"}}case"find":return Wr(e.matcher||{}).map(s=>({tag:s.tagName.toLowerCase(),text:Qo(s.textContent)}));case"getLog":return $a(e.clear);case"clearLog":return Na(),!0;default:return{error:`Unknown command: ${e.command}`}}}function Yu(e,t,n){if(kn&&kn.readyState<=WebSocket.OPEN)return;const s=new WebSocket(e);kn=s;let i=!1;const r=()=>{i||(i=!0,s.send(JSON.stringify({type:"join_room",room:t})))};s.addEventListener("open",()=>{n?s.send(JSON.stringify({type:"auth",token:n})):r()}),s.addEventListener("message",async o=>{let l;try{l=JSON.parse(o.data)}catch{return}if(l.type==="authenticated"){r();return}if(!(l.type!=="agent_command"||l.room!==t)){window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!0}}));try{const c=await ip(l);s.send(JSON.stringify({type:"agent_command_result",room:t,requestId:l.requestId,result:c}))}finally{window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!1}}))}}}),s.addEventListener("close",()=>{kn===s&&(kn=null)})}function Jo(){kn==null||kn.close(),kn=null}function Xu(){Gu(),window.__backflowAgent={trigger:Pa,fill:_a,scroll:Ou,drag:Uu,getDom:Hu,evaluate:qu,find:Wr,getLog:$a,clearLog:Na,isEnabled:ju}}const ki={primary:"#3b82f6",accent:"#db2777",background:"#111827",surface:"#1f2937",surfaceHover:"#374151",border:"#374151",borderSubtle:"rgba(255,255,255,0.1)",text:"#ffffff",textSecondary:"#d1d5db",textMuted:"#9ca3af",textPlaceholder:"#6b7280",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},Mi={primary:"#000000",accent:"#db2777",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderSubtle:"rgba(0,0,0,0.06)",text:"#111827",textSecondary:"#4b5563",textMuted:"#6b7280",textPlaceholder:"#9ca3af",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},rp={fontFamily:"inherit",headingFontFamily:"inherit",baseFontSize:"14px",headingFontSize:"24px",lineHeight:1.5},op={borderRadius:"8px",borderRadiusLg:"12px",borderRadiusSm:"4px",spacing:"8px",cardPadding:"16px",sectionGap:"12px",containerMaxWidth:"none"},ap={shadow:"0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)",shadowLg:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)",transition:"all 0.15s ease",hoverOpacity:.85,scrollBehavior:"smooth"},lp={buttonStyle:"solid",buttonRadius:"8px",inputStyle:"outline",inputRadius:"8px",cardBorder:!0,cardShadow:!1};function cp(e){const t=String(e).replace("#","");if(t.length!==6&&t.length!==3)return-1;const n=t.length===3?t.split("").map(o=>o+o).join(""):t,s=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),r=parseInt(n.slice(4,6),16);return(s*299+i*587+r*114)/1e3}function Ko(e){const t=cp(e);return t<0?"dark":t>128?"light":"dark"}const hp=/(^|\s)(bg-white|bg-gray-50|bg-gray-100|bg-gray-200|bg-indigo-50|bg-blue-50|text-gray-6\d\d|text-gray-7\d\d|text-gray-8\d\d|text-black|text-gray-9\d\d|border-gray-2\d\d|border-gray-3\d\d)/,up=/(^|\s)(bg-gray-8\d\d|bg-gray-9\d\d|bg-slate-8\d\d|bg-slate-9\d\d|bg-zinc-8\d\d|bg-zinc-9\d\d|bg-neutral-8\d\d|bg-neutral-9\d\d|bg-black|text-gray-1\d\d|text-gray-2\d\d|text-gray-3\d\d|text-slate-1\d\d|text-slate-2\d\d|text-slate-3\d\d|border-gray-7\d\d|border-gray-8\d\d)/;function dp(e){if(!e||typeof e!="object")return null;const t=e.steps;if(!Array.isArray(t))return null;let n=0,s=0;const i=r=>{if(!r||typeof r!="object")return;const o=r,l=typeof o.className=="string"?o.className:"";hp.test(l)&&n++,up.test(l)&&s++,Array.isArray(o.children)&&o.children.forEach(i),Array.isArray(o.components)&&o.components.forEach(i),o.component&&typeof o.component=="object"&&i(o.component)};return t.forEach(r=>{const o=r.config;o&&typeof o=="object"&&i(o)}),n===s?null:n>s?"light":"dark"}function Qu(e,t,n,s){const i=t!=null&&t.colorMode||e!=null&&e.colorMode||n!=null&&n.colorMode?"declared":"default",r=(t==null?void 0:t.colorMode)??(e==null?void 0:e.colorMode)??(n==null?void 0:n.colorMode)??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),l=r!=="light"?{...ki}:{...Mi};n!=null&&n.primaryColor&&(l.primary=n.primaryColor),n!=null&&n.accentColor&&(l.accent=n.accentColor);const c={...l,...(e==null?void 0:e.colors)||{},...(t==null?void 0:t.colors)||{}};if(s){const x=Ko(s);if(x!==r){const k=x==="light"?Mi:ki;c.text=c.text||k.text,c.textSecondary=c.textSecondary||k.textSecondary,c.textMuted=c.textMuted||k.textMuted,c.textPlaceholder=c.textPlaceholder||k.textPlaceholder,c.surface=c.surface||k.surface,c.surfaceHover=c.surfaceHover||k.surfaceHover,c.border=c.border||k.border,c.borderSubtle=c.borderSubtle||k.borderSubtle}}const h={...rp,...(e==null?void 0:e.typography)||{},...(t==null?void 0:t.typography)||{}},a={...op,...(e==null?void 0:e.layout)||{},...(t==null?void 0:t.layout)||{}},u={...ap,...(e==null?void 0:e.effects)||{},...(t==null?void 0:t.effects)||{}},f={...lp,...(e==null?void 0:e.components)||{},...(t==null?void 0:t.components)||{}},p=(e==null?void 0:e.persistedKeys)||(t==null?void 0:t.persistedKeys),g=(t==null?void 0:t.fullscreen)??(e==null?void 0:e.fullscreen),d={...(e==null?void 0:e.toast)||{},...(t==null?void 0:t.toast)||{}},w=(t==null?void 0:t.startupModal)||(e==null?void 0:e.startupModal),C=(t==null?void 0:t.realtime)||(e==null?void 0:e.realtime);return{colorMode:r,colorModeSource:i,colors:c,typography:h,layout:a,effects:u,components:f,toast:d,persistedKeys:p,fullscreen:g,startupModal:w,realtime:C}}function*Zo(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*Zo(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,s]of Object.entries(e))s&&typeof s=="object"&&(yield*Zo(s,`${t}.${n}`))}}function fp(e){const t={scenes:[],modals:[],widgets:[],actions:[],sources:[]};if(!e)return t;const n=Array.isArray(e.steps)?e.steps:[],s=Array.isArray(e.widgets)?e.widgets:[],i=n.map(a=>{var u;return{label:a.id||"(unnamed)",detail:[a.route,(u=a.config)==null?void 0:u.sceneName,a.requiresAuth?"auth":null].filter(Boolean).join(" · ")}}),r=Object.entries(e.modals||{}).map(([a,u])=>({label:a,detail:[u==null?void 0:u.title,u!=null&&u.popover?"popover":null,u==null?void 0:u.size].filter(Boolean).join(" · ")})),o=s.map(a=>({label:a.id||"(unnamed)",detail:`${Array.isArray(a.components)?a.components.length:0} components`})),l=a=>{var g,d;const u=a.match(/^\$\.steps\[(\d+)\]/);if(u)return((g=n[+u[1]])==null?void 0:g.id)||`step[${u[1]}]`;const f=a.match(/^\$\.widgets\[(\d+)\]/);if(f)return`widget:${((d=s[+f[1]])==null?void 0:d.id)??f[1]}`;const p=a.match(/^\$\.modals\.([^.[]+)/);return p?`modal:${p[1]}`:a.split(".")[1]||"root"},c=[],h=[];for(const[a,u]of Zo(e)){const f=l(u),p=typeof a.endpoint=="string";for(const g of["onClick","action","onSubmit","onChangeAction"])g==="action"&&p||typeof a[g]=="string"&&c.push({label:a[g],detail:f});typeof a.dataSource=="string"&&h.push({label:a.dataSource,detail:[f,a.key?`key: ${a.key}`:null].filter(Boolean).join(" · "),lookup:[a.key,a.dataSource.replace(/^\//,"")].filter(Boolean)})}return{scenes:i,modals:r,widgets:o,actions:c,sources:mp(h)}}function pc(e){return e.startsWith("sdk:")?e.split("(")[0]:e.replace(/^\//,"").split("?")[0]}function mp(e){const t=new Map;for(const n of e){const s=pc(n.label);t.set(s,(t.get(s)||0)+1)}return e.map(n=>{const s=t.get(pc(n.label))||1;return s>1?{...n,duplicateCount:s}:n})}function pp(e,t){for(const n of t||[]){const s=e==null?void 0:e[n];if(s!==void 0)return s}}function gp({inventory:e,registry:t,colors:n}){const[s,i]=m.useState({}),r=a=>i(u=>({...u,[a]:!u[a]})),o=a=>m.createElement("span",{key:"caret",style:{display:"inline-block",width:"10px",color:n.muted,transform:a?"rotate(90deg)":"none",transition:"transform 0.12s ease"}},"▸"),l=a=>m.createElement("pre",{key:"json",style:{margin:"4px 0 8px 18px",padding:"8px 10px",borderRadius:"8px",background:"rgba(0,0,0,0.35)",color:n.text,fontSize:"10px",lineHeight:1.5,maxHeight:"180px",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"}},a===void 0?"not loaded in this scene":JSON.stringify(a,null,2)),c=(a,u,f)=>{const p=!!s[u],g=m.createElement(f?"button":"div",{key:"head",...f?{onClick:()=>r(u)}:{},style:{display:"flex",alignItems:"flex-start",gap:"6px",width:"100%",padding:"4px 0",background:"none",border:"none",textAlign:"left",cursor:f?"pointer":"default",fontSize:"11px",color:n.text}},f?o(p):null,m.createElement("div",{key:"label",style:{minWidth:0,flex:1}},m.createElement("div",{key:"name",style:{fontFamily:"monospace",wordBreak:"break-all"}},a.label),a.detail?m.createElement("div",{key:"detail",style:{color:n.muted,fontSize:"10px"}},a.detail):null),a.duplicateCount?m.createElement("span",{key:"dup",title:"Same endpoint used by multiple sources",style:{flex:"0 0 auto",padding:"1px 6px",borderRadius:"999px",fontSize:"9px",fontWeight:700,color:n.warn,border:`1px solid ${n.warn}`}},`×${a.duplicateCount}`):null);return m.createElement("div",{key:u,style:{paddingLeft:"16px"}},g,f&&p?l(pp(t,a.lookup)):null)},h=(a,u)=>{const f=e[a],p=!!s[a];return m.createElement("div",{key:a,style:{borderBottom:`1px solid ${n.border}`}},m.createElement("button",{key:"head",onClick:()=>r(a),style:{display:"flex",alignItems:"center",gap:"6px",width:"100%",padding:"8px 0",background:"none",border:"none",cursor:"pointer",textAlign:"left",fontSize:"11px",fontWeight:600,color:n.text}},o(p),m.createElement("span",{key:"label"},u),m.createElement("span",{key:"count",style:{color:n.muted,marginLeft:"auto"}},String(f.length))),p?m.createElement("div",{key:"items",style:{paddingBottom:"6px"}},...f.map((g,d)=>c(g,`${a}-${d}`,a==="sources"))):null)};return m.createElement("div",null,h("scenes","Scenes"),h("modals","Modals"),h("widgets","Widgets"),h("actions","Actions"),h("sources","Sources"))}const Ju={activity:xt.FiActivity,"alert-triangle":xt.FiAlertTriangle,archive:xt.FiArchive,"arrow-left":xt.FiArrowLeft,"arrow-right":xt.FiArrowRight,check:xt.FiCheck,"check-circle":xt.FiCheckCircle,"check-square":xt.FiCheckSquare,"chevron-down":xt.FiChevronDown,clock:xt.FiClock,copy:xt.FiCopy,"corner-up-left":xt.FiCornerUpLeft,cpu:xt.FiCpu,eye:xt.FiEye,"eye-off":xt.FiEyeOff,film:xt.FiFilm,image:xt.FiImage,"log-out":xt.FiLogOut,mail:xt.FiMail,"maximize-2":xt.FiMaximize2,"message-square":xt.FiMessageSquare,"minimize-2":xt.FiMinimize2,octagon:xt.FiOctagon,paperclip:xt.FiPaperclip,pin:Xo.LuPin,"pin-off":Xo.LuPinOff,play:xt.FiPlay,plus:xt.FiPlus,"refresh-cw":xt.FiRefreshCw,"rotate-cw":xt.FiRotateCw,save:xt.FiSave,search:xt.FiSearch,send:xt.FiSend,"share-2":xt.FiShare2,sun:xt.FiSun,"trash-2":xt.FiTrash2,user:xt.FiUser,"user-x":xt.FiUserX,x:xt.FiX},yp={...Ju,"fa-play":Zm.FaPlay,sparkles:Xo.LuSparkles};function bp(e){return Ju[e]||null}function vp(e){return yp[e]||null}function Ia(e,t,n){const s=vp(e);return s?m.createElement(s,{size:t,style:{...n,flexShrink:0}}):m.createElement("span",{style:{fontSize:`${t}px`,lineHeight:1,...n}},e)}const xp=["go_to_step","navigate","show_modal","execute_workflow","fetch","set_data","scroll_to","auth","toast","show_toast","copy_to_clipboard"],wp=new Set(["go_back","toggle_theme","close_modal","toggle_select","accept_startup_modal","decline_startup_modal"]);function*ta(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*ta(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,s]of Object.entries(e))s&&typeof s=="object"&&(yield*ta(s,`${t}.${n}`))}}function Sp(e){const t=e.trim().match(/^(GET|POST|PUT|PATCH|DELETE)\s+(.+)$/i);return t?{method:t[1].toUpperCase(),path:t[2].trim()}:{method:"GET",path:e.trim()}}function Cp(e){const t=e.startsWith("$.modals.")?"modal":"",n=[...e.matchAll(/\.(?:components|children|content)\[(\d+)\]/g)].map(s=>s[1]);if(n.length!==0)return`${t}-${n.join("-")}`}function kp(e){var k;const t=[],n=(S,T,P,I,L)=>t.push({level:S,code:T,where:P,msg:I,targetKey:L});if(!e)return t;const s=Array.isArray(e.steps)?e.steps:[],i=new Set(s.map(S=>S.id)),r=new Set(s.map(S=>S.route).filter(Boolean)),o=new Set(Object.keys(e.modals||{})),l=Array.isArray(e.widgets)?e.widgets:[],c=new Set(l.map(S=>S.id).filter(Boolean)),h=[...ta(e)],a=S=>{var L,O;const T=S.match(/^\$\.steps\[(\d+)\]/);if(T)return((L=s[+T[1]])==null?void 0:L.id)||`step[${T[1]}]`;const P=S.match(/^\$\.widgets\[(\d+)\]/);if(P)return`widget:${((O=l[+P[1]])==null?void 0:O.id)??P[1]}`;const I=S.match(/^\$\.modals\.([^.[]+)/);return I?`modal:${I[1]}`:S.split(".")[1]||"root"},u=[],f=[],p=[],g=[];for(const[S,T]of h){const P=`${a(T)}`,I=Cp(T),L=typeof S.endpoint=="string",O=typeof S.onClick=="string"?S.onClick:!L&&typeof S.action=="string"?S.action:"";for(const H of["onClick","action","onSubmit","onChangeAction"])H==="action"&&L||typeof S[H]=="string"&&u.push({raw:S[H],where:P,node:S,targetKey:I});typeof S.widgetId=="string"&&!c.has(S.widgetId)&&n("error","WIDGET_MISSING",P,`widgetId "${S.widgetId}" not declared in widgets[]`,I),typeof S.dataSource=="string"&&f.push({src:S.dataSource,where:P,node:S,targetKey:I}),S.feedback&&O&&p.push({fb:S.feedback,where:P,node:S,targetKey:I}),typeof S.preload=="string"&&u.push({raw:`fetch:${S.preload}`,where:P,node:S,targetKey:I}),S.upgradeScene&&!i.has(S.upgradeScene)&&n("error","SCENE_MISSING",P,`upgradeScene "${S.upgradeScene}" has no step`,I)}(k=e.config)!=null&&k.startupModal&&!o.has(e.config.startupModal)&&n("error","MODAL_MISSING","config",`startupModal "${e.config.startupModal}" not in modals`),r.has("/")||n("warn","NO_ROOT_ROUTE","config",'no step declares "route": "/"');const d=(S,T,P,I)=>{var D;const L=S.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);if(L){d(L[2].trim(),T,P,I),d(L[3].trim(),T,P,I);return}const O=S.split(";").map(j=>j.trim()).filter(Boolean);if(O.length>1){for(const j of O)d(j,T,P,I);return}const H=O[0]??"";if(!H)return n("error","ACTION_EMPTY",T,"empty action string",I);if(wp.has(H)||/^sdk:[\w.]+\(/.test(H))return;const U=H.split(":")[0],q=H.slice(U.length+1);if(U.includes("{{"))return n("warn","ACTION_DYNAMIC",T,`"${H}" — verb resolves at runtime`,I);if(!xp.includes(U))return n("error","ACTION_UNKNOWN",T,`"${H}" — renderer will no-op`,I);if(U==="go_to_step"){const j=q.split("?")[0].trim();j!=="/"&&!i.has(j)&&!r.has(j)&&n("error","SCENE_MISSING",T,`go_to_step:${j} has no step or route`,I);return}if(U==="show_modal"){!o.has(q)&&!q.includes("|")&&n("error","MODAL_MISSING",T,`show_modal:${q} not in modals`,I);return}if(U==="set_data"){/^([\w.]+)=(.*)$/.test(q)||n("error","SETDATA_MALFORMED",T,`set_data must be "key=value", got "${q}"`,I);return}if(U==="auth"){/^(login|register|forgot|reset|logout)$/.test(q)||n("error","AUTH_UNKNOWN",T,`auth:${q} unsupported`,I);return}if(U==="scroll_to"){h.some(([J])=>J.scrollTarget===q||J.id===q)||n("warn","ANCHOR_MISSING",T,`scroll_to:${q} — no matching anchor`,I);return}if(U==="navigate"||U==="toast"||U==="show_toast"||U==="copy_to_clipboard")return;const{method:X,path:V}=Sp(q);g.push({method:X,path:V}),!V.startsWith("/")&&!/^https?:/.test(V)&&!V.includes("{{")&&n("error","ROUTE_RELATIVE",T,`route "${V}" should start with "/"`,I),X!=="GET"&&(!P.refetchScope&&!P.optimistic&&n("warn","NO_REFETCH",T,`${X} ${V} has no refetchScope`,I),X==="DELETE"&&!((D=P.confirmation)!=null&&D.enabled)&&n("warn","NO_CONFIRM",T,`DELETE ${V} has no confirmation`,I),!P.onSuccess&&!P.onError&&n("warn","NO_FEEDBACK_UI",T,`${X} ${V} has no onSuccess/onError`,I))};for(const{raw:S,where:T,node:P,targetKey:I}of u)d(String(S),T,P,I);for(const{fb:S,where:T,node:P,targetKey:I}of p){const L=typeof S=="string"?S:S==null?void 0:S.transport;if(!L){n("error","FEEDBACK_NO_TRANSPORT",T,"feedback missing transport",I);continue}if(["sse","ws","websocket","poll"].includes(L)||n("error","FEEDBACK_TRANSPORT",T,`unknown transport "${L}"`,I),typeof S=="object"&&S.subscribeUrl){const U=String(S.subscribeUrl).trim(),q=U.startsWith("{{")&&U.endsWith("}}")?U.slice(2,-2).trim():U;/^(subscribe\.|\[.+\])/.test(q)||q.startsWith("/")||n("warn","SUBSCRIBE_URL",T,`subscribeUrl "${U}" may not resolve from the response`,I)}const O=String(P.onClick||P.action||"");O.includes("execute_workflow:")||O.includes("fetch:")||n("warn","FEEDBACK_ORPHAN",T,"feedback declared but node triggers no route",I)}const w=new Set(f.map(({node:S})=>S.key).filter(Boolean));for(const{src:S,where:T,node:P,targetKey:I}of f)S.startsWith("sdk:")?/^sdk:[\w.]+\(/.test(S)||n("error","SDK_CALL_MALFORMED",T,`"${S}" is not a callable sdk expression`,I):!S.startsWith("/")&&!/^https?:/.test(S)?n("error","DATASOURCE_RELATIVE",T,`dataSource "${S}" should start with "/"`,I):S.includes("{{")||g.push({method:"GET",path:S}),P.key||n("warn","NO_DATA_KEY",T,`list "${S}" has no key — refetch matching will miss it`,I),P.realtime&&!P.realtime.mode&&n("error","REALTIME_NO_MODE",T,"realtime block missing mode (sse|ws)",I);const C=new Set(g.map(S=>S.path.replace(/^\//,""))),x=JSON.stringify(e).match(/\{\{\[(.+?)\]/g)||[];for(const S of new Set(x)){const T=S.slice(3,-1);!w.has(T)&&!C.has(T)&&n("warn","REGISTRY_REF","bindings",`{{[${T}]}} has no list key or route producing it`)}return n("ok","SUMMARY","workflow",`${s.length} scenes · ${o.size} modals · ${c.size} widgets · ${u.length} actions · ${f.length} sources`),t}function Mp(){if(typeof window>"u")return!1;try{if(window.localStorage.getItem("backflow_dev_diagnostics")==="1")return!0;if(window.localStorage.getItem("backflow_dev_diagnostics")==="0")return!1}catch{}const e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"||e==="[::1]"||e.endsWith(".local")||e.endsWith(".localhost")}const ri={error:"#f87171",warn:"#fbbf24",ok:"#4ade80"};function Ep({workflow:e,ctx:t}){const[n,s]=m.useState(!1),[i,r]=m.useState("issues"),[o,l]=m.useState("all"),c=m.useMemo(()=>kp(e),[e]),h=m.useMemo(()=>fp(e),[e]),a={error:c.filter(D=>D.level==="error").length,warn:c.filter(D=>D.level==="warn").length},u=t.colorMode==="dark",f=u?"#12121a":"#ffffff",p=u?"#e5e7eb":"#1f2937",g=u?"#6b7280":"#9ca3af",d=u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",w=a.error||a.warn,C=a.error?ri.error:ri.warn,x=D=>{if(typeof document>"u")return null;if(D.targetKey){const nt=typeof CSS<"u"&&CSS.escape?CSS.escape(D.targetKey):D.targetKey.replace(/(["\\])/g,"\\$1"),it=document.querySelector(`[data-component-key="${nt}"]`);if(it)return it}const j=D.where.match(/^widget:(.+)$/);if(!j)return null;const J=typeof CSS<"u"&&CSS.escape?CSS.escape(`-${j[1]}-`):`-${j[1]}-`.replace(/(["\\])/g,"\\$1");return document.querySelector(`[data-component-key*="${J}"]`)},k=(D,j)=>{D.scrollIntoView({behavior:"smooth",block:"center"});const J=D.style.outline,nt=D.style.outlineOffset;D.style.outline=`3px solid ${ri[j]}`,D.style.outlineOffset="3px",window.setTimeout(()=>{D.style.outline=J,D.style.outlineOffset=nt},1800)},S=D=>{var it,Q;const j=x(D);if(j){k(j,D.level);return}const J=D.where.match(/^modal:([^\s]+)/);J&&((it=t.openModal)==null||it.call(t,J[1])),D.where&&!D.where.includes(":")&&D.where!=="workflow"&&D.where!==t.sceneId&&((Q=t.navigateToScene)==null||Q.call(t,D.where)),window.setTimeout(()=>{const ut=x(D);ut&&k(ut,D.level)},80)},T=m.useCallback(()=>{const D=h.sources.map(j=>{var J;for(const nt of j.lookup||[])if(((J=t.registry)==null?void 0:J[nt])!==void 0)return{...j,loaded:!0,registryKey:nt,data:t.registry[nt]};return{...j,loaded:!1,registryKey:null,data:null}});return{generatedAt:new Date().toISOString(),sceneId:t.sceneId,authenticated:t.isAuthenticated,counts:{errors:a.error,warnings:a.warn,issues:a.error+a.warn,total:c.length},inventory:{scenes:h.scenes.length,modals:h.modals.length,widgets:h.widgets.length,actions:h.actions.length,sources:h.sources.length},issues:c,data:{...h,sources:D},runtime:{sceneDataKeys:Object.keys(t.sceneData||{}).sort(),registryKeys:Object.keys(t.registry||{}).sort()}}},[a.error,a.warn,t,h,c]);m.useEffect(()=>{if(typeof window>"u")return;const D={getReport:()=>T(),sendReport:async()=>{const j=T();return t.submitReport?t.submitReport(j):{submitted:!1,report:j}}};return window.__backflowDiagnostics=D,()=>{window.__backflowDiagnostics===D&&delete window.__backflowDiagnostics}},[T,t.submitReport]);const P=m.createElement("button",{key:"bf-diag-toggle","aria-label":"UI diagnostics",onClick:()=>s(D=>!D),style:{position:"fixed",bottom:"20px",right:"20px",zIndex:10060,width:"44px",height:"44px",borderRadius:"999px",border:`1px solid ${d}`,background:f,color:w?C:g,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:"0 6px 24px rgba(0,0,0,0.35)"}},Ia("activity",18),w?m.createElement("span",{key:"count",style:{position:"absolute",top:"-4px",right:"-4px",minWidth:"18px",height:"18px",padding:"0 4px",borderRadius:"999px",background:C,color:"#0b0b0f",fontSize:"10px",fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center"}},String(w)):null);if(!n)return m.createElement(m.Fragment,null,P);const I=o==="all"?c:c.filter(D=>D.level===o),L=()=>{const D=T(),j=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),J=URL.createObjectURL(j),nt=document.createElement("a");nt.href=J,nt.download="diagnostics.json",nt.click(),URL.revokeObjectURL(J)},O=(D,j)=>m.createElement("button",{key:D,onClick:()=>r(D),style:{padding:"4px 10px",borderRadius:"999px",border:"none",cursor:"pointer",fontSize:"11px",fontWeight:600,background:i===D?"#8b5cf6":"transparent",color:i===D?"#ffffff":g}},j),H=(D,j)=>m.createElement("button",{key:D,onClick:()=>l(D),style:{padding:"2px 8px",borderRadius:"999px",border:`1px solid ${o===D?"#8b5cf6":d}`,cursor:"pointer",fontSize:"10px",background:"transparent",color:o===D?"#a78bfa":g}},j),U=(D,j)=>m.createElement(D.level==="ok"?"div":"button",{key:`${D.code}-${j}`,...D.level!=="ok"?{onClick:()=>S(D)}:{},style:{display:"flex",gap:"8px",width:"100%",padding:"7px 0",borderBottom:`1px solid ${d}`,borderLeft:"none",borderRight:"none",borderTop:"none",background:"transparent",fontSize:"11px",lineHeight:1.45,textAlign:"left",cursor:D.level==="ok"?"default":"pointer"}},m.createElement("span",{key:"dot",style:{flex:"0 0 auto",width:"6px",height:"6px",marginTop:"5px",borderRadius:"999px",background:ri[D.level]}}),m.createElement("div",{key:"body",style:{minWidth:0}},m.createElement("div",{key:"head",style:{color:g,fontSize:"10px",fontFamily:"monospace"}},`${D.code} · ${D.where}`),m.createElement("div",{key:"msg",style:{color:p}},D.msg))),q=(D,j)=>m.createElement("div",{key:D,style:{display:"flex",gap:"8px",padding:"6px 0",borderBottom:`1px solid ${d}`,fontSize:"11px"}},m.createElement("span",{key:"k",style:{color:g,flex:"0 0 92px"}},D),m.createElement("span",{key:"v",style:{color:p,fontFamily:"monospace",wordBreak:"break-all"}},j||"—")),X=[q("scene",t.sceneId),q("auth",t.isAuthenticated?"authenticated":"anonymous"),q("sceneData",Object.keys(t.sceneData||{}).sort().join(", ")),q("registry",Object.keys(t.registry||{}).sort().join(", "))],V=m.createElement("div",{key:"bf-diag-panel",style:{position:"fixed",bottom:"74px",right:"20px",zIndex:10060,width:"min(420px, calc(100vw - 40px))",maxHeight:"min(60vh, 520px)",display:"flex",flexDirection:"column",borderRadius:"16px",border:`1px solid ${d}`,background:f,color:p,boxShadow:"0 20px 60px rgba(0,0,0,0.45)",overflow:"hidden"}},m.createElement("div",{key:"head",style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderBottom:`1px solid ${d}`}},m.createElement("span",{key:"title",style:{fontSize:"12px",fontWeight:700,marginRight:"auto"}},"UI diagnostics"),m.createElement("button",{key:"export-json",onClick:L,style:{padding:"4px 9px",borderRadius:"999px",border:`1px solid ${d}`,background:"transparent",color:g,cursor:"pointer",fontSize:"11px",fontWeight:600}},"Export JSON"),O("issues",`Issues ${a.error+a.warn}`),O("runtime","Runtime"),O("data","Data")),i==="issues"?m.createElement("div",{key:"filters",style:{display:"flex",gap:"6px",padding:"8px 14px 4px"}},H("all",`All ${c.length}`),H("error",`Errors ${a.error}`),H("warn",`Warnings ${a.warn}`)):null,m.createElement("div",{key:"body",style:{padding:"4px 14px 14px",overflowY:"auto",flex:1}},...i==="issues"?I.map(U):i==="runtime"?X:[m.createElement(gp,{key:"data-tree",inventory:h,registry:t.registry||{},colors:{text:p,muted:g,border:d,warn:ri.warn}})]));return m.createElement(m.Fragment,null,V,P)}function Tp(e,t){return!(t.enabled??Mp())||!e?null:m.createElement(Ep,{key:"bf-dev-diagnostics",workflow:e,ctx:t})}const Da=m.createContext({});function La(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const Vr=m.createContext(null),za=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Ap extends Ra.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=this.props.sizeRef.current;s.height=n.offsetHeight||0,s.width=n.offsetWidth||0,s.top=n.offsetTop,s.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Rp({children:e,isPresent:t}){const n=m.useId(),s=m.useRef(null),i=m.useRef({width:0,height:0,top:0,left:0}),{nonce:r}=m.useContext(za);return m.useInsertionEffect(()=>{const{width:o,height:l,top:c,left:h}=i.current;if(t||!s.current||!o||!l)return;s.current.dataset.motionPopId=n;const a=document.createElement("style");return r&&(a.nonce=r),document.head.appendChild(a),a.sheet&&a.sheet.insertRule(`
|
|
1
|
+
"use strict";var Km=Object.defineProperty;var Zm=(e,t,n)=>t in e?Km(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var go=(e,t,n)=>Zm(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),tp=require("react-icons/fa"),xt=require("react-icons/fi"),Xo=require("react-icons/lu"),cn=require("react/jsx-runtime"),dc=require("@squeed/flow-sdk"),Wu=require("react-dom");function ep(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ra=ep(m);function wn(e){return e.length>2e3?`${e.slice(0,2e3)}…`:e}const np={button:"button, [role='button'], a",link:"a",input:"input, textarea",select:"select",textarea:"textarea",checkbox:"input[type='checkbox']"};function Qo(e){return(e||"").replace(/\s+/g," ").trim().toLowerCase()}function sp(e,t){if(!t.text)return!0;const n=Qo(t.text);return[e.textContent,e.placeholder,e.getAttribute("aria-label"),e.getAttribute("title"),e.value].map(Qo).some(s=>t.exact?s===n:s.includes(n))}function Wr(e,t=document){const n=e.role?np[e.role]||e.role:"*";return Array.from(t.querySelectorAll(n)).filter(s=>e.name&&s.getAttribute("name")!==e.name?!1:sp(s,e))}function Tn(e,t=document){return Wr(e,t)[e.index??0]||null}let is=!1;function ju(e){is=e}function Vu(){return is}function Ou(e,t){if(!is)return!1;const n=Tn(e,t);return n?(n.click(),!0):!1}async function ip(e){if(!is)return!1;const t=Tn(e);if(!t)return!1;let n=document.getElementById("__bf_remote_cursor");n||(n=document.body.appendChild(document.createElement("div")),n.id="__bf_remote_cursor",n.innerHTML='<svg width="22" height="30" viewBox="0 0 22 30" fill="none"><path d="M2 1.5 L2 22.5 L7.6 17.4 L11.2 25.8 L14.8 24.2 L11.3 16.1 L18.6 15.6 Z" fill="#fff" stroke="#111" stroke-width="1.6" stroke-linejoin="round"/></svg>',Object.assign(n.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",width:"22px",height:"30px",transition:"left 180ms ease, top 180ms ease",filter:"drop-shadow(0 2px 3px rgba(0,0,0,0.45))",left:`${window.innerWidth-40}px`,top:`${window.innerHeight-48}px`}));const s=t.getBoundingClientRect();await new Promise(r=>requestAnimationFrame(()=>{n.style.left=`${s.left+s.width/2}px`,n.style.top=`${s.top+s.height/2}px`,r()})),await new Promise(r=>setTimeout(r,180));const i=document.body.appendChild(document.createElement("div"));return Object.assign(i.style,{position:"fixed",zIndex:"2147483646",pointerEvents:"none",left:n.style.left,top:n.style.top,width:"34px",height:"34px",border:"2px solid rgba(255,60,60,0.9)",borderRadius:"50%",transform:"translate(-50%, -50%)"}),i.animate([{transform:"translate(-50%, -50%) scale(0.3)",opacity:.9},{transform:"translate(-50%, -50%) scale(1)",opacity:0}],{duration:450}).finished.finally(()=>i.remove()),await n.animate([{transform:"scale(1)"},{transform:"scale(0.8)"},{transform:"scale(1)"}],{duration:160}).finished.catch(()=>{}),t.click(),!0}function Pa(e,t,n){var s;if(!is)return!1;const i=Tn({...e,role:e.role||"input"},n);if(!i)return!1;const r=i.tagName==="TEXTAREA"?window.HTMLTextAreaElement:window.HTMLInputElement,o=(s=Object.getOwnPropertyDescriptor(r.prototype,"value"))==null?void 0:s.set;return o==null||o.call(i,t),i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0})),!0}function fc(e){const t=getComputedStyle(e).overflowY;return(t==="auto"||t==="scroll")&&e.scrollHeight>e.clientHeight}function rp(){const e=document.getElementById("__bf_remote_cursor"),t=Number.parseFloat((e==null?void 0:e.style.left)||""),n=Number.parseFloat((e==null?void 0:e.style.top)||"");let s=Number.isFinite(t)&&Number.isFinite(n)?document.elementFromPoint(t,n):null;for(;s instanceof HTMLElement;){if(fc(s))return s;s=s.parentElement}return Array.from(document.querySelectorAll("body *")).find(fc)||null}function Uu(e,t="down",n=600,s){const i=Math.min(Math.max(Math.abs(n),1),2e3),r=e?Tn(e,s):null;if(e&&!r)return!1;if(r)return r.scrollIntoView({behavior:"smooth",block:"center"}),!0;const o=rp();return o?(o.scrollBy({top:t==="down"?i:-i,behavior:"smooth"}),!0):(window.scrollBy({top:t==="down"?i:-i,behavior:"smooth"}),!0)}function Hu(e,t,n){if(!is)return!1;const s=Tn(e,n),i=Tn(t,n);if(!s||!i)return!1;const r=s.getBoundingClientRect(),o=i.getBoundingClientRect(),l=1,c=(p,g,d,w)=>g.dispatchEvent(new PointerEvent(p,{bubbles:!0,cancelable:!0,clientX:d,clientY:w,pointerId:l,pointerType:"touch",isPrimary:!0})),h=r.left+r.width/2,a=r.top+r.height/2,u=o.left+o.width/2,f=o.top+o.height/2;return c("pointerdown",s,h,a),c("pointermove",i,u,f),c("pointerup",i,u,f),!0}function qu(e,t=1e5){const n=e?Tn(e):document.documentElement;if(!n)return"";const s=Math.min(Math.max(Math.floor(t),1),1e5);return n.outerHTML.slice(0,s)}async function Gu(e){if(!is)return!1;const t=Object.getPrototypeOf(async function(){}).constructor,n=await new t(e)();return JSON.parse(JSON.stringify(n??null))}let mc=!1,Ds=[];const op=500;function ye(e){Ds.push(e),Ds.length>op&&Ds.shift()}function Yu(){if(mc)return;mc=!0,window.addEventListener("error",i=>{ye({type:"error",message:i.message,source:i.filename,line:i.lineno,col:i.colno,time:Date.now()})}),window.addEventListener("unhandledrejection",i=>{var r;ye({type:"rejection",message:((r=i.reason)==null?void 0:r.message)||String(i.reason),time:Date.now()})}),["error","warn"].forEach(i=>{const r=console[i].bind(console);console[i]=(...o)=>{ye({type:"console",level:i,message:o.map(String).join(" "),time:Date.now()}),r(...o)}});const e=window.fetch.bind(window);window.fetch=async(...i)=>{var r,o;const l=typeof i[0]=="string"?i[0]:i[0].url,c=(((r=i[1])==null?void 0:r.method)||"GET").toUpperCase(),h=typeof((o=i[1])==null?void 0:o.body)=="string"?wn(i[1].body):void 0;try{const a=await e(...i),u=(a.headers.get("content-type")||"").includes("text/event-stream");if(a.body&&!u?a.clone().text().then(f=>ye({type:"network",method:c,url:l,status:a.status,ok:a.ok,requestBody:h,responseBody:wn(f),time:Date.now()})).catch(()=>ye({type:"network",method:c,url:l,status:a.status,ok:a.ok,requestBody:h,time:Date.now()})):ye({type:"network",method:c,url:l,status:a.status,ok:a.ok,requestBody:h,time:Date.now()}),u&&a.body){const[f,p]=a.body.tee();a.__bfBody=f,Object.defineProperty(a,"body",{get:()=>f});const g=p.getReader(),d=new TextDecoder;(async()=>{try{for(;;){const{done:w,value:C}=await g.read();if(w)break;d.decode(C,{stream:!0}).split(`
|
|
2
|
+
`).filter(x=>x.startsWith("data:")).forEach(x=>ye({type:"sse",url:l,data:wn(x.slice(5).trim()),time:Date.now()}))}}catch{}})()}return a}catch(a){throw ye({type:"network",method:c,url:l,error:(a==null?void 0:a.message)||String(a),requestBody:h,time:Date.now()}),a}};const t=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(i,r,...o){return this.__bfMethod=i,this.__bfUrl=r,t.apply(this,[i,r,...o])},XMLHttpRequest.prototype.send=function(i){return this.addEventListener("loadend",()=>{ye({type:"network",method:this.__bfMethod||"GET",url:this.__bfUrl||"",status:this.status,ok:this.status>=200&&this.status<300,requestBody:typeof i=="string"?wn(i):void 0,responseBody:typeof this.responseText=="string"?wn(this.responseText):void 0,time:Date.now()})}),n.call(this,i)};const s=window.WebSocket;if(window.WebSocket=new Proxy(s,{construct(i,r){const o=new i(...r),l=String(r[0]);o.addEventListener("open",()=>ye({type:"ws",url:l,direction:"open",time:Date.now()})),o.addEventListener("close",()=>ye({type:"ws",url:l,direction:"close",time:Date.now()})),o.addEventListener("error",()=>ye({type:"ws",url:l,direction:"error",time:Date.now()})),o.addEventListener("message",h=>ye({type:"ws",url:l,direction:"receive",data:wn(String(h.data)),time:Date.now()}));const c=o.send.bind(o);return o.send=h=>(ye({type:"ws",url:l,direction:"send",data:wn(String(h)),time:Date.now()}),c(h)),o}}),"EventSource"in window){const i=window.EventSource;window.EventSource=new Proxy(i,{construct(r,o){const l=new r(...o),c=String(o[0]);return l.addEventListener("message",h=>ye({type:"sse",url:c,data:wn(String(h.data)),time:Date.now()})),l.addEventListener("error",()=>ye({type:"ws",url:c,direction:"error",time:Date.now()})),l}})}}function _a(e=!1){const t=[...Ds];return e&&(Ds=[]),t}function $a(){Ds=[]}let kn=null;async function ap(e){var t,n;switch(e.command){case"trigger":return ip(e.matcher||{});case"fill":return Pa(e.matcher||{},e.value??"");case"scroll":return Uu(e.matcher,e.direction,e.amount);case"drag":return!e.sourceMatcher||!e.targetMatcher?!1:Hu(e.sourceMatcher,e.targetMatcher);case"getDom":return qu(e.matcher,e.maxChars);case"evaluate":return Gu(e.script??"");case"diagnostics":{const s=window.__backflowDiagnostics;return s?e.submit?(t=s.sendReport)==null?void 0:t.call(s):(n=s.getReport)==null?void 0:n.call(s):{error:"UI diagnostics unavailable"}}case"find":return Wr(e.matcher||{}).map(s=>({tag:s.tagName.toLowerCase(),text:Qo(s.textContent)}));case"getLog":return _a(e.clear);case"clearLog":return $a(),!0;default:return{error:`Unknown command: ${e.command}`}}}function Xu(e,t,n){if(kn&&kn.readyState<=WebSocket.OPEN)return;const s=new WebSocket(e);kn=s;let i=!1;const r=()=>{i||(i=!0,s.send(JSON.stringify({type:"join_room",room:t})))};s.addEventListener("open",()=>{n?s.send(JSON.stringify({type:"auth",token:n})):r()}),s.addEventListener("message",async o=>{let l;try{l=JSON.parse(o.data)}catch{return}if(l.type==="authenticated"){r();return}if(!(l.type!=="agent_command"||l.room!==t)){window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!0}}));try{const c=await ap(l);s.send(JSON.stringify({type:"agent_command_result",room:t,requestId:l.requestId,result:c}))}finally{window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!1}}))}}}),s.addEventListener("close",()=>{kn===s&&(kn=null)})}function Jo(){kn==null||kn.close(),kn=null}function Qu(){Yu(),window.__backflowAgent={trigger:Ou,fill:Pa,scroll:Uu,drag:Hu,getDom:qu,evaluate:Gu,find:Wr,getLog:_a,clearLog:$a,isEnabled:Vu}}const ki={primary:"#3b82f6",accent:"#db2777",background:"#111827",surface:"#1f2937",surfaceHover:"#374151",border:"#374151",borderSubtle:"rgba(255,255,255,0.1)",text:"#ffffff",textSecondary:"#d1d5db",textMuted:"#9ca3af",textPlaceholder:"#6b7280",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},Mi={primary:"#000000",accent:"#db2777",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderSubtle:"rgba(0,0,0,0.06)",text:"#111827",textSecondary:"#4b5563",textMuted:"#6b7280",textPlaceholder:"#9ca3af",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},lp={fontFamily:"inherit",headingFontFamily:"inherit",baseFontSize:"14px",headingFontSize:"24px",lineHeight:1.5},cp={borderRadius:"8px",borderRadiusLg:"12px",borderRadiusSm:"4px",spacing:"8px",cardPadding:"16px",sectionGap:"12px",containerMaxWidth:"none"},hp={shadow:"0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)",shadowLg:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)",transition:"all 0.15s ease",hoverOpacity:.85,scrollBehavior:"smooth"},up={buttonStyle:"solid",buttonRadius:"8px",inputStyle:"outline",inputRadius:"8px",cardBorder:!0,cardShadow:!1};function dp(e){const t=String(e).replace("#","");if(t.length!==6&&t.length!==3)return-1;const n=t.length===3?t.split("").map(o=>o+o).join(""):t,s=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),r=parseInt(n.slice(4,6),16);return(s*299+i*587+r*114)/1e3}function Ko(e){const t=dp(e);return t<0?"dark":t>128?"light":"dark"}const fp=/(^|\s)(bg-white|bg-gray-50|bg-gray-100|bg-gray-200|bg-indigo-50|bg-blue-50|text-gray-6\d\d|text-gray-7\d\d|text-gray-8\d\d|text-black|text-gray-9\d\d|border-gray-2\d\d|border-gray-3\d\d)/,mp=/(^|\s)(bg-gray-8\d\d|bg-gray-9\d\d|bg-slate-8\d\d|bg-slate-9\d\d|bg-zinc-8\d\d|bg-zinc-9\d\d|bg-neutral-8\d\d|bg-neutral-9\d\d|bg-black|text-gray-1\d\d|text-gray-2\d\d|text-gray-3\d\d|text-slate-1\d\d|text-slate-2\d\d|text-slate-3\d\d|border-gray-7\d\d|border-gray-8\d\d)/;function pp(e){if(!e||typeof e!="object")return null;const t=e.steps;if(!Array.isArray(t))return null;let n=0,s=0;const i=r=>{if(!r||typeof r!="object")return;const o=r,l=typeof o.className=="string"?o.className:"";fp.test(l)&&n++,mp.test(l)&&s++,Array.isArray(o.children)&&o.children.forEach(i),Array.isArray(o.components)&&o.components.forEach(i),o.component&&typeof o.component=="object"&&i(o.component)};return t.forEach(r=>{const o=r.config;o&&typeof o=="object"&&i(o)}),n===s?null:n>s?"light":"dark"}function Ju(e,t,n,s){const i=t!=null&&t.colorMode||e!=null&&e.colorMode||n!=null&&n.colorMode?"declared":"default",r=(t==null?void 0:t.colorMode)??(e==null?void 0:e.colorMode)??(n==null?void 0:n.colorMode)??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),l=r!=="light"?{...ki}:{...Mi};n!=null&&n.primaryColor&&(l.primary=n.primaryColor),n!=null&&n.accentColor&&(l.accent=n.accentColor);const c={...l,...(e==null?void 0:e.colors)||{},...(t==null?void 0:t.colors)||{}};if(s){const x=Ko(s);if(x!==r){const k=x==="light"?Mi:ki;c.text=c.text||k.text,c.textSecondary=c.textSecondary||k.textSecondary,c.textMuted=c.textMuted||k.textMuted,c.textPlaceholder=c.textPlaceholder||k.textPlaceholder,c.surface=c.surface||k.surface,c.surfaceHover=c.surfaceHover||k.surfaceHover,c.border=c.border||k.border,c.borderSubtle=c.borderSubtle||k.borderSubtle}}const h={...lp,...(e==null?void 0:e.typography)||{},...(t==null?void 0:t.typography)||{}},a={...cp,...(e==null?void 0:e.layout)||{},...(t==null?void 0:t.layout)||{}},u={...hp,...(e==null?void 0:e.effects)||{},...(t==null?void 0:t.effects)||{}},f={...up,...(e==null?void 0:e.components)||{},...(t==null?void 0:t.components)||{}},p=(e==null?void 0:e.persistedKeys)||(t==null?void 0:t.persistedKeys),g=(t==null?void 0:t.fullscreen)??(e==null?void 0:e.fullscreen),d={...(e==null?void 0:e.toast)||{},...(t==null?void 0:t.toast)||{}},w=(t==null?void 0:t.startupModal)||(e==null?void 0:e.startupModal),C=(t==null?void 0:t.realtime)||(e==null?void 0:e.realtime);return{colorMode:r,colorModeSource:i,colors:c,typography:h,layout:a,effects:u,components:f,toast:d,persistedKeys:p,fullscreen:g,startupModal:w,realtime:C}}function*Zo(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*Zo(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,s]of Object.entries(e))s&&typeof s=="object"&&(yield*Zo(s,`${t}.${n}`))}}function gp(e){const t={scenes:[],modals:[],widgets:[],actions:[],sources:[]};if(!e)return t;const n=Array.isArray(e.steps)?e.steps:[],s=Array.isArray(e.widgets)?e.widgets:[],i=n.map(a=>{var u;return{label:a.id||"(unnamed)",detail:[a.route,(u=a.config)==null?void 0:u.sceneName,a.requiresAuth?"auth":null].filter(Boolean).join(" · ")}}),r=Object.entries(e.modals||{}).map(([a,u])=>({label:a,detail:[u==null?void 0:u.title,u!=null&&u.popover?"popover":null,u==null?void 0:u.size].filter(Boolean).join(" · ")})),o=s.map(a=>({label:a.id||"(unnamed)",detail:`${Array.isArray(a.components)?a.components.length:0} components`})),l=a=>{var g,d;const u=a.match(/^\$\.steps\[(\d+)\]/);if(u)return((g=n[+u[1]])==null?void 0:g.id)||`step[${u[1]}]`;const f=a.match(/^\$\.widgets\[(\d+)\]/);if(f)return`widget:${((d=s[+f[1]])==null?void 0:d.id)??f[1]}`;const p=a.match(/^\$\.modals\.([^.[]+)/);return p?`modal:${p[1]}`:a.split(".")[1]||"root"},c=[],h=[];for(const[a,u]of Zo(e)){const f=l(u),p=typeof a.endpoint=="string";for(const g of["onClick","action","onSubmit","onChangeAction"])g==="action"&&p||typeof a[g]=="string"&&c.push({label:a[g],detail:f});typeof a.dataSource=="string"&&h.push({label:a.dataSource,detail:[f,a.key?`key: ${a.key}`:null].filter(Boolean).join(" · "),lookup:[a.key,a.dataSource.replace(/^\//,"")].filter(Boolean)})}return{scenes:i,modals:r,widgets:o,actions:c,sources:yp(h)}}function pc(e){return e.startsWith("sdk:")?e.split("(")[0]:e.replace(/^\//,"").split("?")[0]}function yp(e){const t=new Map;for(const n of e){const s=pc(n.label);t.set(s,(t.get(s)||0)+1)}return e.map(n=>{const s=t.get(pc(n.label))||1;return s>1?{...n,duplicateCount:s}:n})}function bp(e,t){for(const n of t||[]){const s=e==null?void 0:e[n];if(s!==void 0)return s}}function vp({inventory:e,registry:t,colors:n}){const[s,i]=m.useState({}),r=a=>i(u=>({...u,[a]:!u[a]})),o=a=>m.createElement("span",{key:"caret",style:{display:"inline-block",width:"10px",color:n.muted,transform:a?"rotate(90deg)":"none",transition:"transform 0.12s ease"}},"▸"),l=a=>m.createElement("pre",{key:"json",style:{margin:"4px 0 8px 18px",padding:"8px 10px",borderRadius:"8px",background:"rgba(0,0,0,0.35)",color:n.text,fontSize:"10px",lineHeight:1.5,maxHeight:"180px",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"}},a===void 0?"not loaded in this scene":JSON.stringify(a,null,2)),c=(a,u,f)=>{const p=!!s[u],g=m.createElement(f?"button":"div",{key:"head",...f?{onClick:()=>r(u)}:{},style:{display:"flex",alignItems:"flex-start",gap:"6px",width:"100%",padding:"4px 0",background:"none",border:"none",textAlign:"left",cursor:f?"pointer":"default",fontSize:"11px",color:n.text}},f?o(p):null,m.createElement("div",{key:"label",style:{minWidth:0,flex:1}},m.createElement("div",{key:"name",style:{fontFamily:"monospace",wordBreak:"break-all"}},a.label),a.detail?m.createElement("div",{key:"detail",style:{color:n.muted,fontSize:"10px"}},a.detail):null),a.duplicateCount?m.createElement("span",{key:"dup",title:"Same endpoint used by multiple sources",style:{flex:"0 0 auto",padding:"1px 6px",borderRadius:"999px",fontSize:"9px",fontWeight:700,color:n.warn,border:`1px solid ${n.warn}`}},`×${a.duplicateCount}`):null);return m.createElement("div",{key:u,style:{paddingLeft:"16px"}},g,f&&p?l(bp(t,a.lookup)):null)},h=(a,u)=>{const f=e[a],p=!!s[a];return m.createElement("div",{key:a,style:{borderBottom:`1px solid ${n.border}`}},m.createElement("button",{key:"head",onClick:()=>r(a),style:{display:"flex",alignItems:"center",gap:"6px",width:"100%",padding:"8px 0",background:"none",border:"none",cursor:"pointer",textAlign:"left",fontSize:"11px",fontWeight:600,color:n.text}},o(p),m.createElement("span",{key:"label"},u),m.createElement("span",{key:"count",style:{color:n.muted,marginLeft:"auto"}},String(f.length))),p?m.createElement("div",{key:"items",style:{paddingBottom:"6px"}},...f.map((g,d)=>c(g,`${a}-${d}`,a==="sources"))):null)};return m.createElement("div",null,h("scenes","Scenes"),h("modals","Modals"),h("widgets","Widgets"),h("actions","Actions"),h("sources","Sources"))}const Ku={activity:xt.FiActivity,"alert-triangle":xt.FiAlertTriangle,archive:xt.FiArchive,"arrow-left":xt.FiArrowLeft,"arrow-right":xt.FiArrowRight,check:xt.FiCheck,"check-circle":xt.FiCheckCircle,"check-square":xt.FiCheckSquare,"chevron-down":xt.FiChevronDown,clock:xt.FiClock,copy:xt.FiCopy,"corner-up-left":xt.FiCornerUpLeft,cpu:xt.FiCpu,eye:xt.FiEye,"eye-off":xt.FiEyeOff,film:xt.FiFilm,image:xt.FiImage,"log-out":xt.FiLogOut,mail:xt.FiMail,"maximize-2":xt.FiMaximize2,"message-square":xt.FiMessageSquare,"minimize-2":xt.FiMinimize2,octagon:xt.FiOctagon,paperclip:xt.FiPaperclip,pin:Xo.LuPin,"pin-off":Xo.LuPinOff,play:xt.FiPlay,plus:xt.FiPlus,"refresh-cw":xt.FiRefreshCw,"rotate-cw":xt.FiRotateCw,save:xt.FiSave,search:xt.FiSearch,send:xt.FiSend,"share-2":xt.FiShare2,sun:xt.FiSun,"trash-2":xt.FiTrash2,user:xt.FiUser,"user-x":xt.FiUserX,x:xt.FiX},xp={...Ku,"fa-play":tp.FaPlay,sparkles:Xo.LuSparkles};function wp(e){return Ku[e]||null}function Sp(e){return xp[e]||null}function Na(e,t,n){const s=Sp(e);return s?m.createElement(s,{size:t,style:{...n,flexShrink:0}}):m.createElement("span",{style:{fontSize:`${t}px`,lineHeight:1,...n}},e)}const Cp=["go_to_step","navigate","show_modal","execute_workflow","fetch","set_data","scroll_to","auth","toast","show_toast","copy_to_clipboard"],kp=new Set(["go_back","toggle_theme","close_modal","toggle_select","accept_startup_modal","decline_startup_modal"]);function*ta(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*ta(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,s]of Object.entries(e))s&&typeof s=="object"&&(yield*ta(s,`${t}.${n}`))}}function Mp(e){const t=e.trim().match(/^(GET|POST|PUT|PATCH|DELETE)\s+(.+)$/i);return t?{method:t[1].toUpperCase(),path:t[2].trim()}:{method:"GET",path:e.trim()}}function Ep(e){const t=e.startsWith("$.modals.")?"modal":"",n=[...e.matchAll(/\.(?:components|children|content)\[(\d+)\]/g)].map(s=>s[1]);if(n.length!==0)return`${t}-${n.join("-")}`}function Tp(e){var k;const t=[],n=(S,T,P,I,L)=>t.push({level:S,code:T,where:P,msg:I,targetKey:L});if(!e)return t;const s=Array.isArray(e.steps)?e.steps:[],i=new Set(s.map(S=>S.id)),r=new Set(s.map(S=>S.route).filter(Boolean)),o=new Set(Object.keys(e.modals||{})),l=Array.isArray(e.widgets)?e.widgets:[],c=new Set(l.map(S=>S.id).filter(Boolean)),h=[...ta(e)],a=S=>{var L,O;const T=S.match(/^\$\.steps\[(\d+)\]/);if(T)return((L=s[+T[1]])==null?void 0:L.id)||`step[${T[1]}]`;const P=S.match(/^\$\.widgets\[(\d+)\]/);if(P)return`widget:${((O=l[+P[1]])==null?void 0:O.id)??P[1]}`;const I=S.match(/^\$\.modals\.([^.[]+)/);return I?`modal:${I[1]}`:S.split(".")[1]||"root"},u=[],f=[],p=[],g=[];for(const[S,T]of h){const P=`${a(T)}`,I=Ep(T),L=typeof S.endpoint=="string",O=typeof S.onClick=="string"?S.onClick:!L&&typeof S.action=="string"?S.action:"";for(const H of["onClick","action","onSubmit","onChangeAction"])H==="action"&&L||typeof S[H]=="string"&&u.push({raw:S[H],where:P,node:S,targetKey:I});typeof S.widgetId=="string"&&!c.has(S.widgetId)&&n("error","WIDGET_MISSING",P,`widgetId "${S.widgetId}" not declared in widgets[]`,I),typeof S.dataSource=="string"&&f.push({src:S.dataSource,where:P,node:S,targetKey:I}),S.feedback&&O&&p.push({fb:S.feedback,where:P,node:S,targetKey:I}),typeof S.preload=="string"&&u.push({raw:`fetch:${S.preload}`,where:P,node:S,targetKey:I}),S.upgradeScene&&!i.has(S.upgradeScene)&&n("error","SCENE_MISSING",P,`upgradeScene "${S.upgradeScene}" has no step`,I)}(k=e.config)!=null&&k.startupModal&&!o.has(e.config.startupModal)&&n("error","MODAL_MISSING","config",`startupModal "${e.config.startupModal}" not in modals`),r.has("/")||n("warn","NO_ROOT_ROUTE","config",'no step declares "route": "/"');const d=(S,T,P,I)=>{var D;const L=S.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);if(L){d(L[2].trim(),T,P,I),d(L[3].trim(),T,P,I);return}const O=S.split(";").map(V=>V.trim()).filter(Boolean);if(O.length>1){for(const V of O)d(V,T,P,I);return}const H=O[0]??"";if(!H)return n("error","ACTION_EMPTY",T,"empty action string",I);if(kp.has(H)||/^sdk:[\w.]+\(/.test(H))return;const U=H.split(":")[0],q=H.slice(U.length+1);if(U.includes("{{"))return n("warn","ACTION_DYNAMIC",T,`"${H}" — verb resolves at runtime`,I);if(!Cp.includes(U))return n("error","ACTION_UNKNOWN",T,`"${H}" — renderer will no-op`,I);if(U==="go_to_step"){const V=q.split("?")[0].trim();V!=="/"&&!i.has(V)&&!r.has(V)&&n("error","SCENE_MISSING",T,`go_to_step:${V} has no step or route`,I);return}if(U==="show_modal"){!o.has(q)&&!q.includes("|")&&n("error","MODAL_MISSING",T,`show_modal:${q} not in modals`,I);return}if(U==="set_data"){/^([\w.]+)=(.*)$/.test(q)||n("error","SETDATA_MALFORMED",T,`set_data must be "key=value", got "${q}"`,I);return}if(U==="auth"){/^(login|register|forgot|reset|logout)$/.test(q)||n("error","AUTH_UNKNOWN",T,`auth:${q} unsupported`,I);return}if(U==="scroll_to"){h.some(([J])=>J.scrollTarget===q||J.id===q)||n("warn","ANCHOR_MISSING",T,`scroll_to:${q} — no matching anchor`,I);return}if(U==="navigate"||U==="toast"||U==="show_toast"||U==="copy_to_clipboard")return;const{method:X,path:j}=Mp(q);g.push({method:X,path:j}),!j.startsWith("/")&&!/^https?:/.test(j)&&!j.includes("{{")&&n("error","ROUTE_RELATIVE",T,`route "${j}" should start with "/"`,I),X!=="GET"&&(!P.refetchScope&&!P.optimistic&&n("warn","NO_REFETCH",T,`${X} ${j} has no refetchScope`,I),X==="DELETE"&&!((D=P.confirmation)!=null&&D.enabled)&&n("warn","NO_CONFIRM",T,`DELETE ${j} has no confirmation`,I),!P.onSuccess&&!P.onError&&n("warn","NO_FEEDBACK_UI",T,`${X} ${j} has no onSuccess/onError`,I))};for(const{raw:S,where:T,node:P,targetKey:I}of u)d(String(S),T,P,I);for(const{fb:S,where:T,node:P,targetKey:I}of p){const L=typeof S=="string"?S:S==null?void 0:S.transport;if(!L){n("error","FEEDBACK_NO_TRANSPORT",T,"feedback missing transport",I);continue}if(["sse","ws","websocket","poll"].includes(L)||n("error","FEEDBACK_TRANSPORT",T,`unknown transport "${L}"`,I),typeof S=="object"&&S.subscribeUrl){const U=String(S.subscribeUrl).trim(),q=U.startsWith("{{")&&U.endsWith("}}")?U.slice(2,-2).trim():U;/^(subscribe\.|\[.+\])/.test(q)||q.startsWith("/")||n("warn","SUBSCRIBE_URL",T,`subscribeUrl "${U}" may not resolve from the response`,I)}const O=String(P.onClick||P.action||"");O.includes("execute_workflow:")||O.includes("fetch:")||n("warn","FEEDBACK_ORPHAN",T,"feedback declared but node triggers no route",I)}const w=new Set(f.map(({node:S})=>S.key).filter(Boolean));for(const{src:S,where:T,node:P,targetKey:I}of f)S.startsWith("sdk:")?/^sdk:[\w.]+\(/.test(S)||n("error","SDK_CALL_MALFORMED",T,`"${S}" is not a callable sdk expression`,I):!S.startsWith("/")&&!/^https?:/.test(S)?n("error","DATASOURCE_RELATIVE",T,`dataSource "${S}" should start with "/"`,I):S.includes("{{")||g.push({method:"GET",path:S}),P.key||n("warn","NO_DATA_KEY",T,`list "${S}" has no key — refetch matching will miss it`,I),P.realtime&&!P.realtime.mode&&n("error","REALTIME_NO_MODE",T,"realtime block missing mode (sse|ws)",I);const C=new Set(g.map(S=>S.path.replace(/^\//,""))),x=JSON.stringify(e).match(/\{\{\[(.+?)\]/g)||[];for(const S of new Set(x)){const T=S.slice(3,-1);!w.has(T)&&!C.has(T)&&n("warn","REGISTRY_REF","bindings",`{{[${T}]}} has no list key or route producing it`)}return n("ok","SUMMARY","workflow",`${s.length} scenes · ${o.size} modals · ${c.size} widgets · ${u.length} actions · ${f.length} sources`),t}function Ap(){if(typeof window>"u")return!1;try{if(window.localStorage.getItem("backflow_dev_diagnostics")==="1")return!0;if(window.localStorage.getItem("backflow_dev_diagnostics")==="0")return!1}catch{}const e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"||e==="[::1]"||e.endsWith(".local")||e.endsWith(".localhost")}const ri={error:"#f87171",warn:"#fbbf24",ok:"#4ade80"};function Rp({workflow:e,ctx:t}){const[n,s]=m.useState(!1),[i,r]=m.useState("issues"),[o,l]=m.useState("all"),c=m.useMemo(()=>Tp(e),[e]),h=m.useMemo(()=>gp(e),[e]),a={error:c.filter(D=>D.level==="error").length,warn:c.filter(D=>D.level==="warn").length},u=t.colorMode==="dark",f=u?"#12121a":"#ffffff",p=u?"#e5e7eb":"#1f2937",g=u?"#6b7280":"#9ca3af",d=u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",w=a.error||a.warn,C=a.error?ri.error:ri.warn,x=D=>{if(typeof document>"u")return null;if(D.targetKey){const nt=typeof CSS<"u"&&CSS.escape?CSS.escape(D.targetKey):D.targetKey.replace(/(["\\])/g,"\\$1"),it=document.querySelector(`[data-component-key="${nt}"]`);if(it)return it}const V=D.where.match(/^widget:(.+)$/);if(!V)return null;const J=typeof CSS<"u"&&CSS.escape?CSS.escape(`-${V[1]}-`):`-${V[1]}-`.replace(/(["\\])/g,"\\$1");return document.querySelector(`[data-component-key*="${J}"]`)},k=(D,V)=>{D.scrollIntoView({behavior:"smooth",block:"center"});const J=D.style.outline,nt=D.style.outlineOffset;D.style.outline=`3px solid ${ri[V]}`,D.style.outlineOffset="3px",window.setTimeout(()=>{D.style.outline=J,D.style.outlineOffset=nt},1800)},S=D=>{var it,Q;const V=x(D);if(V){k(V,D.level);return}const J=D.where.match(/^modal:([^\s]+)/);J&&((it=t.openModal)==null||it.call(t,J[1])),D.where&&!D.where.includes(":")&&D.where!=="workflow"&&D.where!==t.sceneId&&((Q=t.navigateToScene)==null||Q.call(t,D.where)),window.setTimeout(()=>{const ut=x(D);ut&&k(ut,D.level)},80)},T=m.useCallback(()=>{const D=h.sources.map(V=>{var J;for(const nt of V.lookup||[])if(((J=t.registry)==null?void 0:J[nt])!==void 0)return{...V,loaded:!0,registryKey:nt,data:t.registry[nt]};return{...V,loaded:!1,registryKey:null,data:null}});return{generatedAt:new Date().toISOString(),sceneId:t.sceneId,authenticated:t.isAuthenticated,counts:{errors:a.error,warnings:a.warn,issues:a.error+a.warn,total:c.length},inventory:{scenes:h.scenes.length,modals:h.modals.length,widgets:h.widgets.length,actions:h.actions.length,sources:h.sources.length},issues:c,data:{...h,sources:D},runtime:{sceneDataKeys:Object.keys(t.sceneData||{}).sort(),registryKeys:Object.keys(t.registry||{}).sort()}}},[a.error,a.warn,t,h,c]);m.useEffect(()=>{if(typeof window>"u")return;const D={getReport:()=>T(),sendReport:async()=>{const V=T();return t.submitReport?t.submitReport(V):{submitted:!1,report:V}}};return window.__backflowDiagnostics=D,()=>{window.__backflowDiagnostics===D&&delete window.__backflowDiagnostics}},[T,t.submitReport]);const P=m.createElement("button",{key:"bf-diag-toggle","aria-label":"UI diagnostics",onClick:()=>s(D=>!D),style:{position:"fixed",bottom:"20px",right:"20px",zIndex:10060,width:"44px",height:"44px",borderRadius:"999px",border:`1px solid ${d}`,background:f,color:w?C:g,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:"0 6px 24px rgba(0,0,0,0.35)"}},Na("activity",18),w?m.createElement("span",{key:"count",style:{position:"absolute",top:"-4px",right:"-4px",minWidth:"18px",height:"18px",padding:"0 4px",borderRadius:"999px",background:C,color:"#0b0b0f",fontSize:"10px",fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center"}},String(w)):null);if(!n)return m.createElement(m.Fragment,null,P);const I=o==="all"?c:c.filter(D=>D.level===o),L=()=>{const D=T(),V=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),J=URL.createObjectURL(V),nt=document.createElement("a");nt.href=J,nt.download="diagnostics.json",nt.click(),URL.revokeObjectURL(J)},O=(D,V)=>m.createElement("button",{key:D,onClick:()=>r(D),style:{padding:"4px 10px",borderRadius:"999px",border:"none",cursor:"pointer",fontSize:"11px",fontWeight:600,background:i===D?"#8b5cf6":"transparent",color:i===D?"#ffffff":g}},V),H=(D,V)=>m.createElement("button",{key:D,onClick:()=>l(D),style:{padding:"2px 8px",borderRadius:"999px",border:`1px solid ${o===D?"#8b5cf6":d}`,cursor:"pointer",fontSize:"10px",background:"transparent",color:o===D?"#a78bfa":g}},V),U=(D,V)=>m.createElement(D.level==="ok"?"div":"button",{key:`${D.code}-${V}`,...D.level!=="ok"?{onClick:()=>S(D)}:{},style:{display:"flex",gap:"8px",width:"100%",padding:"7px 0",borderBottom:`1px solid ${d}`,borderLeft:"none",borderRight:"none",borderTop:"none",background:"transparent",fontSize:"11px",lineHeight:1.45,textAlign:"left",cursor:D.level==="ok"?"default":"pointer"}},m.createElement("span",{key:"dot",style:{flex:"0 0 auto",width:"6px",height:"6px",marginTop:"5px",borderRadius:"999px",background:ri[D.level]}}),m.createElement("div",{key:"body",style:{minWidth:0}},m.createElement("div",{key:"head",style:{color:g,fontSize:"10px",fontFamily:"monospace"}},`${D.code} · ${D.where}`),m.createElement("div",{key:"msg",style:{color:p}},D.msg))),q=(D,V)=>m.createElement("div",{key:D,style:{display:"flex",gap:"8px",padding:"6px 0",borderBottom:`1px solid ${d}`,fontSize:"11px"}},m.createElement("span",{key:"k",style:{color:g,flex:"0 0 92px"}},D),m.createElement("span",{key:"v",style:{color:p,fontFamily:"monospace",wordBreak:"break-all"}},V||"—")),X=[q("scene",t.sceneId),q("auth",t.isAuthenticated?"authenticated":"anonymous"),q("sceneData",Object.keys(t.sceneData||{}).sort().join(", ")),q("registry",Object.keys(t.registry||{}).sort().join(", "))],j=m.createElement("div",{key:"bf-diag-panel",style:{position:"fixed",bottom:"74px",right:"20px",zIndex:10060,width:"min(420px, calc(100vw - 40px))",maxHeight:"min(60vh, 520px)",display:"flex",flexDirection:"column",borderRadius:"16px",border:`1px solid ${d}`,background:f,color:p,boxShadow:"0 20px 60px rgba(0,0,0,0.45)",overflow:"hidden"}},m.createElement("div",{key:"head",style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderBottom:`1px solid ${d}`}},m.createElement("span",{key:"title",style:{fontSize:"12px",fontWeight:700,marginRight:"auto"}},"UI diagnostics"),m.createElement("button",{key:"export-json",onClick:L,style:{padding:"4px 9px",borderRadius:"999px",border:`1px solid ${d}`,background:"transparent",color:g,cursor:"pointer",fontSize:"11px",fontWeight:600}},"Export JSON"),O("issues",`Issues ${a.error+a.warn}`),O("runtime","Runtime"),O("data","Data")),i==="issues"?m.createElement("div",{key:"filters",style:{display:"flex",gap:"6px",padding:"8px 14px 4px"}},H("all",`All ${c.length}`),H("error",`Errors ${a.error}`),H("warn",`Warnings ${a.warn}`)):null,m.createElement("div",{key:"body",style:{padding:"4px 14px 14px",overflowY:"auto",flex:1}},...i==="issues"?I.map(U):i==="runtime"?X:[m.createElement(vp,{key:"data-tree",inventory:h,registry:t.registry||{},colors:{text:p,muted:g,border:d,warn:ri.warn}})]));return m.createElement(m.Fragment,null,j,P)}function Pp(e,t){return!(t.enabled??Ap())||!e?null:m.createElement(Rp,{key:"bf-dev-diagnostics",workflow:e,ctx:t})}const Ia=m.createContext({});function Da(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const jr=m.createContext(null),La=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class _p extends Ra.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=this.props.sizeRef.current;s.height=n.offsetHeight||0,s.width=n.offsetWidth||0,s.top=n.offsetTop,s.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function $p({children:e,isPresent:t}){const n=m.useId(),s=m.useRef(null),i=m.useRef({width:0,height:0,top:0,left:0}),{nonce:r}=m.useContext(La);return m.useInsertionEffect(()=>{const{width:o,height:l,top:c,left:h}=i.current;if(t||!s.current||!o||!l)return;s.current.dataset.motionPopId=n;const a=document.createElement("style");return r&&(a.nonce=r),document.head.appendChild(a),a.sheet&&a.sheet.insertRule(`
|
|
3
3
|
[data-motion-pop-id="${n}"] {
|
|
4
4
|
position: absolute !important;
|
|
5
5
|
width: ${o}px !important;
|
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
top: ${c}px !important;
|
|
8
8
|
left: ${h}px !important;
|
|
9
9
|
}
|
|
10
|
-
`),()=>{document.head.removeChild(a)}},[t]),cn.jsx(Ap,{isPresent:t,childRef:s,sizeRef:i,children:Ra.cloneElement(e,{ref:s})})}const Pp=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o})=>{const l=La(_p),c=m.useId(),h=m.useCallback(u=>{l.set(u,!0);for(const f of l.values())if(!f)return;s&&s()},[l,s]),a=m.useMemo(()=>({id:c,initial:t,isPresent:n,custom:i,onExitComplete:h,register:u=>(l.set(u,!1),()=>l.delete(u))}),r?[Math.random(),h]:[n,h]);return m.useMemo(()=>{l.forEach((u,f)=>l.set(f,!1))},[n]),Ra.useEffect(()=>{!n&&!l.size&&s&&s()},[n]),o==="popLayout"&&(e=cn.jsx(Rp,{isPresent:n,children:e})),cn.jsx(Vr.Provider,{value:a,children:e})};function _p(){return new Map}function Ku(e=!0){const t=m.useContext(Vr);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,r=m.useId();m.useEffect(()=>{e&&i(r)},[e]);const o=m.useCallback(()=>e&&s&&s(r),[r,s,e]);return!n&&s?[!1,o]:[!0]}const Ji=e=>e.key||"";function gc(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const Fa=typeof window<"u",Zu=Fa?m.useLayoutEffect:m.useEffect,$p=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1})=>{const[l,c]=Ku(o),h=m.useMemo(()=>gc(e),[e]),a=o&&!l?[]:h.map(Ji),u=m.useRef(!0),f=m.useRef(h),p=La(()=>new Map),[g,d]=m.useState(h),[w,C]=m.useState(h);Zu(()=>{u.current=!1,f.current=h;for(let S=0;S<w.length;S++){const T=Ji(w[S]);a.includes(T)?p.delete(T):p.get(T)!==!0&&p.set(T,!1)}},[w,a.length,a.join("-")]);const x=[];if(h!==g){let S=[...h];for(let T=0;T<w.length;T++){const P=w[T],I=Ji(P);a.includes(I)||(S.splice(T,0,P),x.push(P))}r==="wait"&&x.length&&(S=x),C(gc(S)),d(h);return}process.env.NODE_ENV!=="production"&&r==="wait"&&w.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.`);const{forceRender:k}=m.useContext(Da);return cn.jsx(cn.Fragment,{children:w.map(S=>{const T=Ji(S),P=o&&!l?!1:h===w||a.includes(T),I=()=>{if(p.has(T))p.set(T,!0);else return;let L=!0;p.forEach(O=>{O||(L=!1)}),L&&(k==null||k(),C(f.current),o&&(c==null||c()),s&&s())};return cn.jsx(Pp,{isPresent:P,initial:!u.current||n?void 0:!1,custom:P?void 0:t,presenceAffectsLayout:i,mode:r,onExitComplete:P?void 0:I,children:S},T)})})},Ae=e=>e;let Us=Ae,Tn=Ae;process.env.NODE_ENV!=="production"&&(Us=(e,t)=>{!e&&typeof console<"u"&&console.warn(t)},Tn=(e,t)=>{if(!e)throw new Error(t)});function Ba(e){let t;return()=>(t===void 0&&(t=e()),t)}const zs=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s},Qe=e=>e*1e3,hn=e=>e/1e3,Np={useManualTiming:!1};function Ip(e){let t=new Set,n=new Set,s=!1,i=!1;const r=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(h){r.has(h)&&(c.schedule(h),e()),h(o)}const c={schedule:(h,a=!1,u=!1)=>{const p=u&&s?t:n;return a&&r.add(h),p.has(h)||p.add(h),h},cancel:h=>{n.delete(h),r.delete(h)},process:h=>{if(o=h,s){i=!0;return}s=!0,[t,n]=[n,t],t.forEach(l),t.clear(),s=!1,i&&(i=!1,c.process(h))}};return c}const Ki=["read","resolveKeyframes","update","preRender","render","postRender"],Dp=40;function td(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Ki.reduce((C,x)=>(C[x]=Ip(r),C),{}),{read:l,resolveKeyframes:c,update:h,preRender:a,render:u,postRender:f}=o,p=()=>{const C=performance.now();n=!1,i.delta=s?1e3/60:Math.max(Math.min(C-i.timestamp,Dp),1),i.timestamp=C,i.isProcessing=!0,l.process(i),c.process(i),h.process(i),a.process(i),u.process(i),f.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(p))},g=()=>{n=!0,s=!0,i.isProcessing||e(p)};return{schedule:Ki.reduce((C,x)=>{const k=o[x];return C[x]=(S,T=!1,P=!1)=>(n||g(),k.schedule(S,T,P)),C},{}),cancel:C=>{for(let x=0;x<Ki.length;x++)o[Ki[x]].cancel(C)},state:i,steps:o}}const{schedule:Bt,cancel:An,state:me,steps:yo}=td(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ae,!0),ed=m.createContext({strict:!1}),yc={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"]},Fs={};for(const e in yc)Fs[e]={isEnabled:t=>yc[e].some(n=>!!t[n])};function Lp(e){for(const t in e)Fs[t]={...Fs[t],...e[t]}}const zp=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"]);function Er(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||zp.has(e)}let nd=e=>!Er(e);function Fp(e){e&&(nd=t=>t.startsWith("on")?!Er(t):e(t))}try{Fp(require("@emotion/is-prop-valid").default)}catch{}function Bp(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||(nd(i)||n===!0&&Er(i)||!t&&!Er(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const bc=new Set;function jr(e,t,n){e||bc.has(t)||(console.warn(t),bc.add(t))}function Wp(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...s)=>(process.env.NODE_ENV!=="production"&&jr(!1,"motion() is deprecated. Use motion.create() instead."),e(...s));return new Proxy(n,{get:(s,i)=>i==="create"?e:(t.has(i)||t.set(i,e(i)),t.get(i))})}const Or=m.createContext({});function Ei(e){return typeof e=="string"||Array.isArray(e)}function Ur(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const Wa=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Va=["initial",...Wa];function Hr(e){return Ur(e.animate)||Va.some(t=>Ei(e[t]))}function sd(e){return!!(Hr(e)||e.variants)}function Vp(e,t){if(Hr(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Ei(n)?n:void 0,animate:Ei(s)?s:void 0}}return e.inherit!==!1?t:{}}function jp(e){const{initial:t,animate:n}=Vp(e,m.useContext(Or));return m.useMemo(()=>({initial:t,animate:n}),[vc(t),vc(n)])}function vc(e){return Array.isArray(e)?e.join(" "):e}const Op=Symbol.for("motionComponentSymbol");function Ts(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Up(e,t,n){return m.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):Ts(n)&&(n.current=s))},[t])}const ja=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Hp="framerAppearId",id="data-"+ja(Hp),{schedule:Oa}=td(queueMicrotask,!1),rd=m.createContext({});function qp(e,t,n,s,i){var r,o;const{visualElement:l}=m.useContext(Or),c=m.useContext(ed),h=m.useContext(Vr),a=m.useContext(za).reducedMotion,u=m.useRef(null);s=s||c.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:l,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:a}));const f=u.current,p=m.useContext(rd);f&&!f.projection&&i&&(f.type==="html"||f.type==="svg")&&Gp(u.current,n,i,p);const g=m.useRef(!1);m.useInsertionEffect(()=>{f&&g.current&&f.update(n,h)});const d=n[id],w=m.useRef(!!d&&!(!((r=window.MotionHandoffIsComplete)===null||r===void 0)&&r.call(window,d))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,d)));return Zu(()=>{f&&(g.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),Oa.render(f.render),w.current&&f.animationState&&f.animationState.animateChanges())}),m.useEffect(()=>{f&&(!w.current&&f.animationState&&f.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var C;(C=window.MotionHandoffMarkAsComplete)===null||C===void 0||C.call(window,d)}),w.current=!1))}),f}function Gp(e,t,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:od(e.parent)),e.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||l&&Ts(l),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,layoutScroll:c,layoutRoot:h})}function od(e){if(e)return e.options.allowProjection!==!1?e.projection:od(e.parent)}function Yp({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:s,Component:i}){var r,o;e&&Lp(e);function l(h,a){let u;const f={...m.useContext(za),...h,layoutId:Xp(h)},{isStatic:p}=f,g=jp(h),d=s(h,p);if(!p&&Fa){Qp(f,e);const w=Jp(f);u=w.MeasureLayout,g.visualElement=qp(i,d,f,t,w.ProjectionNode)}return cn.jsxs(Or.Provider,{value:g,children:[u&&g.visualElement?cn.jsx(u,{visualElement:g.visualElement,...f}):null,n(i,h,Up(d,g.visualElement,a),d,p,g.visualElement)]})}l.displayName=`motion.${typeof i=="string"?i:`create(${(o=(r=i.displayName)!==null&&r!==void 0?r:i.name)!==null&&o!==void 0?o:""})`}`;const c=m.forwardRef(l);return c[Op]=i,c}function Xp({layoutId:e}){const t=m.useContext(Da).id;return t&&e!==void 0?t+"-"+e:e}function Qp(e,t){const n=m.useContext(ed).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Us(!1,s):Tn(!1,s)}}function Jp(e){const{drag:t,layout:n}=Fs;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}const Kp=["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 Ua(e){return typeof e!="string"||e.includes("-")?!1:!!(Kp.indexOf(e)>-1||/[A-Z]/u.test(e))}function xc(e){const t=[{},{}];return e==null||e.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Ha(e,t,n,s){if(typeof t=="function"){const[i,r]=xc(s);t=t(n!==void 0?n:e.custom,i,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,r]=xc(s);t=t(n!==void 0?n:e.custom,i,r)}return t}const ea=e=>Array.isArray(e),Zp=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),tg=e=>ea(e)?e[e.length-1]||0:e,ve=e=>!!(e&&e.getVelocity);function yr(e){const t=ve(e)?e.get():e;return Zp(t)?t.toValue():t}function eg({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},s,i,r){const o={latestValues:ng(s,i,r,e),renderState:t()};return n&&(o.onMount=l=>n({props:s,current:l,...o}),o.onUpdate=l=>n(l)),o}const ad=e=>(t,n)=>{const s=m.useContext(Or),i=m.useContext(Vr),r=()=>eg(e,t,s,i);return n?r():La(r)};function ng(e,t,n,s){const i={},r=s(e,{});for(const f in r)i[f]=yr(r[f]);let{initial:o,animate:l}=e;const c=Hr(e),h=sd(e);t&&h&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let a=n?n.initial===!1:!1;a=a||o===!1;const u=a?l:o;if(u&&typeof u!="boolean"&&!Ur(u)){const f=Array.isArray(u)?u:[u];for(let p=0;p<f.length;p++){const g=Ha(e,f[p]);if(g){const{transitionEnd:d,transition:w,...C}=g;for(const x in C){let k=C[x];if(Array.isArray(k)){const S=a?k.length-1:0;k=k[S]}k!==null&&(i[x]=k)}for(const x in d)i[x]=d[x]}}}return i}const Hs=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],is=new Set(Hs),ld=e=>t=>typeof t=="string"&&t.startsWith(e),cd=ld("--"),sg=ld("var(--"),qa=e=>sg(e)?ig.test(e.split("/*")[0].trim()):!1,ig=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,hd=(e,t)=>t&&typeof e=="number"?t.transform(e):e,un=(e,t,n)=>n>t?t:n<e?e:n,qs={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ti={...qs,transform:e=>un(0,1,e)},Zi={...qs,default:1},Ii=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Cn=Ii("deg"),Je=Ii("%"),ct=Ii("px"),rg=Ii("vh"),og=Ii("vw"),wc={...Je,parse:e=>Je.parse(e)/100,transform:e=>Je.transform(e*100)},ag={borderWidth:ct,borderTopWidth:ct,borderRightWidth:ct,borderBottomWidth:ct,borderLeftWidth:ct,borderRadius:ct,radius:ct,borderTopLeftRadius:ct,borderTopRightRadius:ct,borderBottomRightRadius:ct,borderBottomLeftRadius:ct,width:ct,maxWidth:ct,height:ct,maxHeight:ct,top:ct,right:ct,bottom:ct,left:ct,padding:ct,paddingTop:ct,paddingRight:ct,paddingBottom:ct,paddingLeft:ct,margin:ct,marginTop:ct,marginRight:ct,marginBottom:ct,marginLeft:ct,backgroundPositionX:ct,backgroundPositionY:ct},lg={rotate:Cn,rotateX:Cn,rotateY:Cn,rotateZ:Cn,scale:Zi,scaleX:Zi,scaleY:Zi,scaleZ:Zi,skew:Cn,skewX:Cn,skewY:Cn,distance:ct,translateX:ct,translateY:ct,translateZ:ct,x:ct,y:ct,z:ct,perspective:ct,transformPerspective:ct,opacity:Ti,originX:wc,originY:wc,originZ:ct},Sc={...qs,transform:Math.round},Ga={...ag,...lg,zIndex:Sc,size:ct,fillOpacity:Ti,strokeOpacity:Ti,numOctaves:Sc},cg={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},hg=Hs.length;function ug(e,t,n){let s="",i=!0;for(let r=0;r<hg;r++){const o=Hs[r],l=e[o];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(o.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const h=hd(l,Ga[o]);if(!c){i=!1;const a=cg[o]||o;s+=`${a}(${h}) `}n&&(t[o]=h)}}return s=s.trim(),n?s=n(t,i?"":s):i&&(s="none"),s}function Ya(e,t,n){const{style:s,vars:i,transformOrigin:r}=e;let o=!1,l=!1;for(const c in t){const h=t[c];if(is.has(c)){o=!0;continue}else if(cd(c)){i[c]=h;continue}else{const a=hd(h,Ga[c]);c.startsWith("origin")?(l=!0,r[c]=a):s[c]=a}}if(t.transform||(o||n?s.transform=ug(t,e.transform,n):s.transform&&(s.transform="none")),l){const{originX:c="50%",originY:h="50%",originZ:a=0}=r;s.transformOrigin=`${c} ${h} ${a}`}}const dg={offset:"stroke-dashoffset",array:"stroke-dasharray"},fg={offset:"strokeDashoffset",array:"strokeDasharray"};function mg(e,t,n=1,s=0,i=!0){e.pathLength=1;const r=i?dg:fg;e[r.offset]=ct.transform(-s);const o=ct.transform(t),l=ct.transform(n);e[r.array]=`${o} ${l}`}function Cc(e,t,n){return typeof e=="string"?e:ct.transform(t+n*e)}function pg(e,t,n){const s=Cc(t,e.x,e.width),i=Cc(n,e.y,e.height);return`${s} ${i}`}function Xa(e,{attrX:t,attrY:n,attrScale:s,originX:i,originY:r,pathLength:o,pathSpacing:l=1,pathOffset:c=0,...h},a,u){if(Ya(e,h,u),a){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:p,dimensions:g}=e;f.transform&&(g&&(p.transform=f.transform),delete f.transform),g&&(i!==void 0||r!==void 0||p.transform)&&(p.transformOrigin=pg(g,i!==void 0?i:.5,r!==void 0?r:.5)),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),s!==void 0&&(f.scale=s),o!==void 0&&mg(f,o,l,c,!1)}const Qa=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),ud=()=>({...Qa(),attrs:{}}),Ja=e=>typeof e=="string"&&e.toLowerCase()==="svg";function dd(e,{style:t,vars:n},s,i){Object.assign(e.style,t,i&&i.getProjectionStyles(s));for(const r in n)e.style.setProperty(r,n[r])}const fd=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 md(e,t,n,s){dd(e,t,void 0,s);for(const i in t.attrs)e.setAttribute(fd.has(i)?i:ja(i),t.attrs[i])}const Tr={};function gg(e){Object.assign(Tr,e)}function pd(e,{layout:t,layoutId:n}){return is.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Tr[e]||e==="opacity")}function Ka(e,t,n){var s;const{style:i}=e,r={};for(const o in i)(ve(i[o])||t.style&&ve(t.style[o])||pd(o,e)||((s=n==null?void 0:n.getValue(o))===null||s===void 0?void 0:s.liveStyle)!==void 0)&&(r[o]=i[o]);return r}function gd(e,t,n){const s=Ka(e,t,n);for(const i in e)if(ve(e[i])||ve(t[i])){const r=Hs.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=e[i]}return s}function yg(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const kc=["x","y","width","height","cx","cy","r"],bg={useVisualState:ad({scrapeMotionValuesFromProps:gd,createRenderState:ud,onUpdate:({props:e,prevProps:t,current:n,renderState:s,latestValues:i})=>{if(!n)return;let r=!!e.drag;if(!r){for(const l in i)if(is.has(l)){r=!0;break}}if(!r)return;let o=!t;if(t)for(let l=0;l<kc.length;l++){const c=kc[l];e[c]!==t[c]&&(o=!0)}o&&Bt.read(()=>{yg(n,s),Bt.render(()=>{Xa(s,i,Ja(n.tagName),e.transformTemplate),md(n,s)})})}})},vg={useVisualState:ad({scrapeMotionValuesFromProps:Ka,createRenderState:Qa})};function yd(e,t,n){for(const s in t)!ve(t[s])&&!pd(s,n)&&(e[s]=t[s])}function xg({transformTemplate:e},t){return m.useMemo(()=>{const n=Qa();return Ya(n,t,e),Object.assign({},n.vars,n.style)},[t])}function wg(e,t){const n=e.style||{},s={};return yd(s,n,e),Object.assign(s,xg(e,t)),s}function Sg(e,t){const n={},s=wg(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.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=s,n}function Cg(e,t,n,s){const i=m.useMemo(()=>{const r=ud();return Xa(r,t,Ja(s),e.transformTemplate),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};yd(r,e.style,e),i.style={...r,...i.style}}return i}function kg(e=!1){return(n,s,i,{latestValues:r},o)=>{const c=(Ua(n)?Cg:Sg)(s,r,o,n),h=Bp(s,typeof n=="string",e),a=n!==m.Fragment?{...h,...c,ref:i}:{},{children:u}=s,f=m.useMemo(()=>ve(u)?u.get():u,[u]);return m.createElement(n,{...a,children:f})}}function Mg(e,t){return function(s,{forwardMotionProps:i}={forwardMotionProps:!1}){const o={...Ua(s)?bg:vg,preloadedFeatures:e,useRender:kg(i),createVisualElement:t,Component:s};return Yp(o)}}function bd(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}function qr(e,t,n){const s=e.getProps();return Ha(s,t,n!==void 0?n:s.custom,e)}const Eg=Ba(()=>window.ScrollTimeline!==void 0);class Tg{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let s=0;s<this.animations.length;s++)this.animations[s][t]=n}attachTimeline(t,n){const s=this.animations.map(i=>{if(Eg()&&i.attachTimeline)return i.attachTimeline(t);if(typeof n=="function")return n(i)});return()=>{s.forEach((i,r)=>{i&&i(),this.animations[r].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class Ag extends Tg{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}function Za(e,t){return e?e[t]||e.default||e:void 0}const na=2e4;function vd(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<na;)t+=n,s=e.next(t);return t>=na?1/0:t}function tl(e){return typeof e=="function"}function Mc(e,t){e.timeline=t,e.onfinish=null}const el=e=>Array.isArray(e)&&typeof e[0]=="number",Rg={linearEasing:void 0};function Pg(e,t){const n=Ba(e);return()=>{var s;return(s=Rg[t])!==null&&s!==void 0?s:n()}}const Ar=Pg(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),xd=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let r=0;r<i;r++)s+=e(zs(0,i-1,r))+", ";return`linear(${s.substring(0,s.length-2)})`};function wd(e){return!!(typeof e=="function"&&Ar()||!e||typeof e=="string"&&(e in sa||Ar())||el(e)||Array.isArray(e)&&e.every(wd))}const hi=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,sa={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:hi([0,.65,.55,1]),circOut:hi([.55,0,1,.45]),backIn:hi([.31,.01,.66,-.59]),backOut:hi([.33,1.53,.69,.99])};function Sd(e,t){if(e)return typeof e=="function"&&Ar()?xd(e,t):el(e)?hi(e):Array.isArray(e)?e.map(n=>Sd(n,t)||sa.easeOut):sa[e]}const je={x:!1,y:!1};function Cd(){return je.x||je.y}function _g(e,t,n){var s;if(e instanceof Element)return[e];if(typeof e=="string"){let i=document;const r=(s=void 0)!==null&&s!==void 0?s:i.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e)}function kd(e,t){const n=_g(e),s=new AbortController,i={passive:!0,...t,signal:s.signal};return[n,i,()=>s.abort()]}function Ec(e){return t=>{t.pointerType==="touch"||Cd()||e(t)}}function $g(e,t,n={}){const[s,i,r]=kd(e,n),o=Ec(l=>{const{target:c}=l,h=t(l);if(typeof h!="function"||!c)return;const a=Ec(u=>{h(u),c.removeEventListener("pointerleave",a)});c.addEventListener("pointerleave",a,i)});return s.forEach(l=>{l.addEventListener("pointerenter",o,i)}),r}const Md=(e,t)=>t?e===t?!0:Md(e,t.parentElement):!1,nl=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Ng=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Ig(e){return Ng.has(e.tagName)||e.tabIndex!==-1}const ui=new WeakSet;function Tc(e){return t=>{t.key==="Enter"&&e(t)}}function bo(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Dg=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Tc(()=>{if(ui.has(n))return;bo(n,"down");const i=Tc(()=>{bo(n,"up")}),r=()=>bo(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function Ac(e){return nl(e)&&!Cd()}function Lg(e,t,n={}){const[s,i,r]=kd(e,n),o=l=>{const c=l.currentTarget;if(!Ac(l)||ui.has(c))return;ui.add(c);const h=t(l),a=(p,g)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",f),!(!Ac(p)||!ui.has(c))&&(ui.delete(c),typeof h=="function"&&h(p,{success:g}))},u=p=>{a(p,n.useGlobalTarget||Md(c,p.target))},f=p=>{a(p,!1)};window.addEventListener("pointerup",u,i),window.addEventListener("pointercancel",f,i)};return s.forEach(l=>{!Ig(l)&&l.getAttribute("tabindex")===null&&(l.tabIndex=0),(n.useGlobalTarget?window:l).addEventListener("pointerdown",o,i),l.addEventListener("focus",h=>Dg(h,i),i)}),r}function zg(e){return e==="x"||e==="y"?je[e]?null:(je[e]=!0,()=>{je[e]=!1}):je.x||je.y?null:(je.x=je.y=!0,()=>{je.x=je.y=!1})}const Ed=new Set(["width","height","top","left","right","bottom",...Hs]);let br;function Fg(){br=void 0}const Ke={now:()=>(br===void 0&&Ke.set(me.isProcessing||Np.useManualTiming?me.timestamp:performance.now()),br),set:e=>{br=e,queueMicrotask(Fg)}};function sl(e,t){e.indexOf(t)===-1&&e.push(t)}function il(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class rl{constructor(){this.subscriptions=[]}add(t){return sl(this.subscriptions,t),()=>il(this.subscriptions,t)}notify(t,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function Td(e,t){return t?e*(1e3/t):0}const Rc=30,Bg=e=>!isNaN(parseFloat(e));class Wg{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(s,i=!0)=>{const r=Ke.now();this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ke.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Bg(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&jr(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new rl);const s=this.events[t].add(n);return t==="change"?()=>{s(),Bt.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Ke.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Rc)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Rc);return Td(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ai(e,t){return new Wg(e,t)}function Vg(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ai(n))}function jg(e,t){const n=qr(e,t);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const l=tg(r[o]);Vg(e,o,l)}}function Og(e){return!!(ve(e)&&e.add)}function ia(e,t){const n=e.getValue("willChange");if(Og(n))return n.add(t)}function Ad(e){return e.props[id]}const Rd=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Ug=1e-7,Hg=12;function qg(e,t,n,s,i){let r,o,l=0;do o=t+(n-t)/2,r=Rd(o,s,i)-e,r>0?n=o:t=o;while(Math.abs(r)>Ug&&++l<Hg);return o}function Di(e,t,n,s){if(e===t&&n===s)return Ae;const i=r=>qg(r,0,1,e,n);return r=>r===0||r===1?r:Rd(i(r),t,s)}const Pd=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,_d=e=>t=>1-e(1-t),$d=Di(.33,1.53,.69,.99),ol=_d($d),Nd=Pd(ol),Id=e=>(e*=2)<1?.5*ol(e):.5*(2-Math.pow(2,-10*(e-1))),al=e=>1-Math.sin(Math.acos(e)),Dd=_d(al),Ld=Pd(al),zd=e=>/^0[^.\s]+$/u.test(e);function Gg(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||zd(e):!0}const gi=e=>Math.round(e*1e5)/1e5,ll=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Yg(e){return e==null}const Xg=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,cl=(e,t)=>n=>!!(typeof n=="string"&&Xg.test(n)&&n.startsWith(e)||t&&!Yg(n)&&Object.prototype.hasOwnProperty.call(n,t)),Fd=(e,t,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,l]=s.match(ll);return{[e]:parseFloat(i),[t]:parseFloat(r),[n]:parseFloat(o),alpha:l!==void 0?parseFloat(l):1}},Qg=e=>un(0,255,e),vo={...qs,transform:e=>Math.round(Qg(e))},Qn={test:cl("rgb","red"),parse:Fd("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+vo.transform(e)+", "+vo.transform(t)+", "+vo.transform(n)+", "+gi(Ti.transform(s))+")"};function Jg(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const ra={test:cl("#"),parse:Jg,transform:Qn.transform},As={test:cl("hsl","hue"),parse:Fd("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+Je.transform(gi(t))+", "+Je.transform(gi(n))+", "+gi(Ti.transform(s))+")"},be={test:e=>Qn.test(e)||ra.test(e)||As.test(e),parse:e=>Qn.test(e)?Qn.parse(e):As.test(e)?As.parse(e):ra.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Qn.transform(e):As.transform(e)},Kg=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Zg(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(ll))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(Kg))===null||n===void 0?void 0:n.length)||0)>0}const Bd="number",Wd="color",t0="var",e0="var(",Pc="${}",n0=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ri(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const l=t.replace(n0,c=>(be.test(c)?(s.color.push(r),i.push(Wd),n.push(be.parse(c))):c.startsWith(e0)?(s.var.push(r),i.push(t0),n.push(c)):(s.number.push(r),i.push(Bd),n.push(parseFloat(c))),++r,Pc)).split(Pc);return{values:n,split:l,indexes:s,types:i}}function Vd(e){return Ri(e).values}function jd(e){const{split:t,types:n}=Ri(e),s=t.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=t[o],i[o]!==void 0){const l=n[o];l===Bd?r+=gi(i[o]):l===Wd?r+=be.transform(i[o]):r+=i[o]}return r}}const s0=e=>typeof e=="number"?0:e;function i0(e){const t=Vd(e);return jd(e)(t.map(s0))}const Rn={test:Zg,parse:Vd,createTransformer:jd,getAnimatableNone:i0},r0=new Set(["brightness","contrast","saturate","opacity"]);function o0(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(ll)||[];if(!s)return e;const i=n.replace(s,"");let r=r0.has(t)?1:0;return s!==n&&(r*=100),t+"("+r+i+")"}const a0=/\b([a-z-]*)\(.*?\)/gu,oa={...Rn,getAnimatableNone:e=>{const t=e.match(a0);return t?t.map(o0).join(" "):e}},l0={...Ga,color:be,backgroundColor:be,outlineColor:be,fill:be,stroke:be,borderColor:be,borderTopColor:be,borderRightColor:be,borderBottomColor:be,borderLeftColor:be,filter:oa,WebkitFilter:oa},hl=e=>l0[e];function Od(e,t){let n=hl(e);return n!==oa&&(n=Rn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const c0=new Set(["auto","none","0"]);function h0(e,t,n){let s=0,i;for(;s<e.length&&!i;){const r=e[s];typeof r=="string"&&!c0.has(r)&&Ri(r).values.length&&(i=e[s]),s++}if(i&&n)for(const r of t)e[r]=Od(n,i)}const _c=e=>e===qs||e===ct,$c=(e,t)=>parseFloat(e.split(", ")[t]),Nc=(e,t)=>(n,{transform:s})=>{if(s==="none"||!s)return 0;const i=s.match(/^matrix3d\((.+)\)$/u);if(i)return $c(i[1],t);{const r=s.match(/^matrix\((.+)\)$/u);return r?$c(r[1],e):0}},u0=new Set(["x","y","z"]),d0=Hs.filter(e=>!u0.has(e));function f0(e){const t=[];return d0.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Bs={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:Nc(4,13),y:Nc(5,14)};Bs.translateX=Bs.x;Bs.translateY=Bs.y;const Jn=new Set;let aa=!1,la=!1;function Ud(){if(la){const e=Array.from(Jn).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const i=f0(s);i.length&&(n.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{var l;(l=s.getValue(r))===null||l===void 0||l.set(o)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}la=!1,aa=!1,Jn.forEach(e=>e.complete()),Jn.clear()}function Hd(){Jn.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(la=!0)})}function m0(){Hd(),Ud()}class ul{constructor(t,n,s,i,r,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Jn.add(this),aa||(aa=!0,Bt.read(Hd),Bt.resolveKeyframes(Ud))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:i}=this;for(let r=0;r<t.length;r++)if(t[r]===null)if(r===0){const o=i==null?void 0:i.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const c=s.readValue(n,l);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=l),i&&o===void 0&&i.set(t[0])}else t[r]=t[r-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Jn.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Jn.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const qd=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),p0=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function g0(e){const t=p0.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${n??s}`,i]}const y0=4;function Gd(e,t,n=1){Tn(n<=y0,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);const[s,i]=g0(e);if(!s)return;const r=window.getComputedStyle(t).getPropertyValue(s);if(r){const o=r.trim();return qd(o)?parseFloat(o):o}return qa(i)?Gd(i,t,n+1):i}const Yd=e=>t=>t.test(e),b0={test:e=>e==="auto",parse:e=>e},Xd=[qs,ct,Je,Cn,og,rg,b0],Ic=e=>Xd.find(Yd(e));class Qd extends ul{constructor(t,n,s,i,r){super(t,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let h=t[c];if(typeof h=="string"&&(h=h.trim(),qa(h))){const a=Gd(h,n.current);a!==void 0&&(t[c]=a),c===t.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!Ed.has(s)||t.length!==2)return;const[i,r]=t,o=Ic(i),l=Ic(r);if(o!==l)if(_c(o)&&_c(l))for(let c=0;c<t.length;c++){const h=t[c];typeof h=="string"&&(t[c]=parseFloat(h))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let i=0;i<t.length;i++)Gg(t[i])&&s.push(i);s.length&&h0(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Bs[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(s,i).jump(i,!1)}measureEndState(){var t;const{element:n,name:s,unresolvedKeyframes:i}=this;if(!n||!n.current)return;const r=n.getValue(s);r&&r.jump(this.measuredOrigin,!1);const o=i.length-1,l=i[o];i[o]=Bs[s](n.measureViewportBox(),window.getComputedStyle(n.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([c,h])=>{n.getValue(c).set(h)}),this.resolveNoneKeyframes()}}const Dc=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Rn.test(e)||e==="0")&&!e.startsWith("url("));function v0(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function x0(e,t,n,s){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],o=Dc(i,t),l=Dc(r,t);return Us(o===l,`You are trying to animate ${t} from "${i}" to "${r}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${r} via the \`style\` property.`),!o||!l?!1:v0(e)||(n==="spring"||tl(n))&&s}const w0=e=>e!==null;function Gr(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(w0),r=t&&n!=="loop"&&t%2===1?0:i.length-1;return!r||s===void 0?i[r]:s}const S0=40;class Jd{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",...l}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=Ke.now(),this.options={autoplay:t,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,...l},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>S0?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&m0(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=Ke.now(),this.hasAttemptedResolve=!0;const{name:s,type:i,velocity:r,delay:o,onComplete:l,onUpdate:c,isGenerator:h}=this.options;if(!h&&!x0(t,s,i,r))if(o)this.options.duration=0;else{c&&c(Gr(t,this.options,n)),l&&l(),this.resolveFinishedPromise();return}const a=this.initPlayback(t,n);a!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...a},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const Ht=(e,t,n)=>e+(t-e)*n;function xo(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function C0({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let i=0,r=0,o=0;if(!t)i=r=o=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;i=xo(c,l,e+1/3),r=xo(c,l,e),o=xo(c,l,e-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Rr(e,t){return n=>n>0?t:e}const wo=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},k0=[ra,Qn,As],M0=e=>k0.find(t=>t.test(e));function Lc(e){const t=M0(e);if(Us(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(e);return t===As&&(n=C0(n)),n}const zc=(e,t)=>{const n=Lc(e),s=Lc(t);if(!n||!s)return Rr(e,t);const i={...n};return r=>(i.red=wo(n.red,s.red,r),i.green=wo(n.green,s.green,r),i.blue=wo(n.blue,s.blue,r),i.alpha=Ht(n.alpha,s.alpha,r),Qn.transform(i))},E0=(e,t)=>n=>t(e(n)),Li=(...e)=>e.reduce(E0),ca=new Set(["none","hidden"]);function T0(e,t){return ca.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function A0(e,t){return n=>Ht(e,t,n)}function dl(e){return typeof e=="number"?A0:typeof e=="string"?qa(e)?Rr:be.test(e)?zc:_0:Array.isArray(e)?Kd:typeof e=="object"?be.test(e)?zc:R0:Rr}function Kd(e,t){const n=[...e],s=n.length,i=e.map((r,o)=>dl(r)(r,t[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function R0(e,t){const n={...e,...t},s={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(s[i]=dl(e[i])(e[i],t[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function P0(e,t){var n;const s=[],i={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],l=e.indexes[o][i[o]],c=(n=e.values[l])!==null&&n!==void 0?n:0;s[r]=c,i[o]++}return s}const _0=(e,t)=>{const n=Rn.createTransformer(t),s=Ri(e),i=Ri(t);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?ca.has(e)&&!i.values.length||ca.has(t)&&!s.values.length?T0(e,t):Li(Kd(P0(s,i),i.values),n):(Us(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),Rr(e,t))};function Zd(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Ht(e,t,n):dl(e)(e,t)}const $0=5;function tf(e,t,n){const s=Math.max(t-$0,0);return Td(n-e(s),t-s)}const Ut={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},So=.001;function N0({duration:e=Ut.duration,bounce:t=Ut.bounce,velocity:n=Ut.velocity,mass:s=Ut.mass}){let i,r;Us(e<=Qe(Ut.maxDuration),"Spring duration must be 10 seconds or less");let o=1-t;o=un(Ut.minDamping,Ut.maxDamping,o),e=un(Ut.minDuration,Ut.maxDuration,hn(e)),o<1?(i=h=>{const a=h*o,u=a*e,f=a-n,p=ha(h,o),g=Math.exp(-u);return So-f/p*g},r=h=>{const u=h*o*e,f=u*n+n,p=Math.pow(o,2)*Math.pow(h,2)*e,g=Math.exp(-u),d=ha(Math.pow(h,2),o);return(-i(h)+So>0?-1:1)*((f-p)*g)/d}):(i=h=>{const a=Math.exp(-h*e),u=(h-n)*e+1;return-So+a*u},r=h=>{const a=Math.exp(-h*e),u=(n-h)*(e*e);return a*u});const l=5/e,c=D0(i,r,l);if(e=Qe(e),isNaN(c))return{stiffness:Ut.stiffness,damping:Ut.damping,duration:e};{const h=Math.pow(c,2)*s;return{stiffness:h,damping:o*2*Math.sqrt(s*h),duration:e}}}const I0=12;function D0(e,t,n){let s=n;for(let i=1;i<I0;i++)s=s-e(s)/t(s);return s}function ha(e,t){return e*Math.sqrt(1-t*t)}const L0=["duration","bounce"],z0=["stiffness","damping","mass"];function Fc(e,t){return t.some(n=>e[n]!==void 0)}function F0(e){let t={velocity:Ut.velocity,stiffness:Ut.stiffness,damping:Ut.damping,mass:Ut.mass,isResolvedFromDuration:!1,...e};if(!Fc(e,z0)&&Fc(e,L0))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*un(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ut.mass,stiffness:i,damping:r}}else{const n=N0(e);t={...t,...n,mass:Ut.mass},t.isResolvedFromDuration=!0}return t}function ef(e=Ut.visualDuration,t=Ut.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:r},{stiffness:c,damping:h,mass:a,duration:u,velocity:f,isResolvedFromDuration:p}=F0({...n,velocity:-hn(n.velocity||0)}),g=f||0,d=h/(2*Math.sqrt(c*a)),w=o-r,C=hn(Math.sqrt(c/a)),x=Math.abs(w)<5;s||(s=x?Ut.restSpeed.granular:Ut.restSpeed.default),i||(i=x?Ut.restDelta.granular:Ut.restDelta.default);let k;if(d<1){const T=ha(C,d);k=P=>{const I=Math.exp(-d*C*P);return o-I*((g+d*C*w)/T*Math.sin(T*P)+w*Math.cos(T*P))}}else if(d===1)k=T=>o-Math.exp(-C*T)*(w+(g+C*w)*T);else{const T=C*Math.sqrt(d*d-1);k=P=>{const I=Math.exp(-d*C*P),L=Math.min(T*P,300);return o-I*((g+d*C*w)*Math.sinh(L)+T*w*Math.cosh(L))/T}}const S={calculatedDuration:p&&u||null,next:T=>{const P=k(T);if(p)l.done=T>=u;else{let I=0;d<1&&(I=T===0?Qe(g):tf(k,T,P));const L=Math.abs(I)<=s,O=Math.abs(o-P)<=i;l.done=L&&O}return l.value=l.done?o:P,l},toString:()=>{const T=Math.min(vd(S),na),P=xd(I=>S.next(T*I).value,T,30);return T+"ms "+P}};return S}function Bc({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:l,max:c,restDelta:h=.5,restSpeed:a}){const u=e[0],f={done:!1,value:u},p=L=>l!==void 0&&L<l||c!==void 0&&L>c,g=L=>l===void 0?c:c===void 0||Math.abs(l-L)<Math.abs(c-L)?l:c;let d=n*t;const w=u+d,C=o===void 0?w:o(w);C!==w&&(d=C-u);const x=L=>-d*Math.exp(-L/s),k=L=>C+x(L),S=L=>{const O=x(L),H=k(L);f.done=Math.abs(O)<=h,f.value=f.done?C:H};let T,P;const I=L=>{p(f.value)&&(T=L,P=ef({keyframes:[f.value,g(f.value)],velocity:tf(k,L,f.value),damping:i,stiffness:r,restDelta:h,restSpeed:a}))};return I(0),{calculatedDuration:null,next:L=>{let O=!1;return!P&&T===void 0&&(O=!0,S(L),I(L)),T!==void 0&&L>=T?P.next(L-T):(!O&&S(L),f)}}}const B0=Di(.42,0,1,1),W0=Di(0,0,.58,1),nf=Di(.42,0,.58,1),V0=e=>Array.isArray(e)&&typeof e[0]!="number",Wc={linear:Ae,easeIn:B0,easeInOut:nf,easeOut:W0,circIn:al,circInOut:Ld,circOut:Dd,backIn:ol,backInOut:Nd,backOut:$d,anticipate:Id},Vc=e=>{if(el(e)){Tn(e.length===4,"Cubic bezier arrays must contain four numerical values.");const[t,n,s,i]=e;return Di(t,n,s,i)}else if(typeof e=="string")return Tn(Wc[e]!==void 0,`Invalid easing type '${e}'`),Wc[e];return e};function j0(e,t,n){const s=[],i=n||Zd,r=e.length-1;for(let o=0;o<r;o++){let l=i(e[o],e[o+1]);if(t){const c=Array.isArray(t)?t[o]||Ae:t;l=Li(c,l)}s.push(l)}return s}function O0(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const r=e.length;if(Tn(r===t.length,"Both input and output ranges must be the same length"),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=j0(t,s,i),c=l.length,h=a=>{if(o&&a<e[0])return t[0];let u=0;if(c>1)for(;u<e.length-2&&!(a<e[u+1]);u++);const f=zs(e[u],e[u+1],a);return l[u](f)};return n?a=>h(un(e[0],e[r-1],a)):h}function U0(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=zs(0,t,s);e.push(Ht(n,1,i))}}function H0(e){const t=[0];return U0(t,e.length-1),t}function q0(e,t){return e.map(n=>n*t)}function G0(e,t){return e.map(()=>t||nf).splice(0,e.length-1)}function Pr({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=V0(s)?s.map(Vc):Vc(s),r={done:!1,value:t[0]},o=q0(n&&n.length===t.length?n:H0(t),e),l=O0(o,t,{ease:Array.isArray(i)?i:G0(t,i)});return{calculatedDuration:e,next:c=>(r.value=l(c),r.done=c>=e,r)}}const Y0=e=>{const t=({timestamp:n})=>e(n);return{start:()=>Bt.update(t,!0),stop:()=>An(t),now:()=>me.isProcessing?me.timestamp:Ke.now()}},X0={decay:Bc,inertia:Bc,tween:Pr,keyframes:Pr,spring:ef},Q0=e=>e/100;class fl extends Jd{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:c}=this.options;c&&c()};const{name:n,motionValue:s,element:i,keyframes:r}=this.options,o=(i==null?void 0:i.KeyframeResolver)||ul,l=(c,h)=>this.onKeyframesResolved(c,h);this.resolver=new o(r,l,n,s,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=this.options,l=tl(n)?n:X0[n]||Pr;let c,h;l!==Pr&&typeof t[0]!="number"&&(process.env.NODE_ENV!=="production"&&Tn(t.length===2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${t}`),c=Li(Q0,Zd(t[0],t[1])),t=[0,100]);const a=l({...this.options,keyframes:t});r==="mirror"&&(h=l({...this.options,keyframes:[...t].reverse(),velocity:-o})),a.calculatedDuration===null&&(a.calculatedDuration=vd(a));const{calculatedDuration:u}=a,f=u+i,p=f*(s+1)-i;return{generator:a,mirroredGenerator:h,mapPercentToKeyframes:c,calculatedDuration:u,resolvedDuration:f,totalDuration:p}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:s}=this;if(!s){const{keyframes:L}=this.options;return{done:!0,value:L[L.length-1]}}const{finalKeyframe:i,generator:r,mirroredGenerator:o,mapPercentToKeyframes:l,keyframes:c,calculatedDuration:h,totalDuration:a,resolvedDuration:u}=s;if(this.startTime===null)return r.next(0);const{delay:f,repeat:p,repeatType:g,repeatDelay:d,onUpdate:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const C=this.currentTime-f*(this.speed>=0?1:-1),x=this.speed>=0?C<0:C>a;this.currentTime=Math.max(C,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let k=this.currentTime,S=r;if(p){const L=Math.min(this.currentTime,a)/u;let O=Math.floor(L),H=L%1;!H&&L>=1&&(H=1),H===1&&O--,O=Math.min(O,p+1),!!(O%2)&&(g==="reverse"?(H=1-H,d&&(H-=d/u)):g==="mirror"&&(S=o)),k=un(0,1,H)*u}const T=x?{done:!1,value:c[0]}:S.next(k);l&&(T.value=l(T.value));let{done:P}=T;!x&&h!==null&&(P=this.speed>=0?this.currentTime>=a:this.currentTime<=0);const I=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&P);return I&&i!==void 0&&(T.value=Gr(c,this.options,i)),w&&w(T.value),I&&this.finish(),T}get duration(){const{resolved:t}=this;return t?hn(t.calculatedDuration):0}get time(){return hn(this.currentTime)}set time(t){t=Qe(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=hn(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=Y0,onPlay:n,startTime:s}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),n&&n();const i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=s??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const J0=new Set(["opacity","clipPath","filter","transform"]);function K0(e,t,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:l="easeInOut",times:c}={}){const h={[t]:n};c&&(h.offset=c);const a=Sd(l,i);return Array.isArray(a)&&(h.easing=a),e.animate(h,{delay:s,duration:i,easing:Array.isArray(a)?"linear":a,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"})}const Z0=Ba(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),_r=10,ty=2e4;function ey(e){return tl(e.type)||e.type==="spring"||!wd(e.ease)}function ny(e,t){const n=new fl({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let s={done:!1,value:e[0]};const i=[];let r=0;for(;!s.done&&r<ty;)s=n.sample(r),i.push(s.value),r+=_r;return{times:void 0,keyframes:i,duration:r-_r,ease:"linear"}}const sf={anticipate:Id,backInOut:Nd,circInOut:Ld};function sy(e){return e in sf}class jc extends Jd{constructor(t){super(t);const{name:n,motionValue:s,element:i,keyframes:r}=this.options;this.resolver=new Qd(r,(o,l)=>this.onKeyframesResolved(o,l),n,s,i),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:s=300,times:i,ease:r,type:o,motionValue:l,name:c,startTime:h}=this.options;if(!l.owner||!l.owner.current)return!1;if(typeof r=="string"&&Ar()&&sy(r)&&(r=sf[r]),ey(this.options)){const{onComplete:u,onUpdate:f,motionValue:p,element:g,...d}=this.options,w=ny(t,d);t=w.keyframes,t.length===1&&(t[1]=t[0]),s=w.duration,i=w.times,r=w.ease,o="keyframes"}const a=K0(l.owner.current,c,t,{...this.options,duration:s,times:i,ease:r});return a.startTime=h??this.calcStartTime(),this.pendingTimeline?(Mc(a,this.pendingTimeline),this.pendingTimeline=void 0):a.onfinish=()=>{const{onComplete:u}=this.options;l.set(Gr(t,this.options,n)),u&&u(),this.cancel(),this.resolveFinishedPromise()},{animation:a,duration:s,times:i,type:o,ease:r,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return hn(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return hn(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:s}=n;s.currentTime=Qe(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:s}=n;s.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return Ae;const{animation:s}=n;Mc(s,t)}return Ae}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:s,duration:i,type:r,ease:o,times:l}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:h,onUpdate:a,onComplete:u,element:f,...p}=this.options,g=new fl({...p,keyframes:s,duration:i,type:r,ease:o,times:l,isGenerator:!0}),d=Qe(this.time);h.setWithVelocity(g.sample(d-_r).value,g.sample(d).value,_r)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:s,repeatDelay:i,repeatType:r,damping:o,type:l}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:h}=n.owner.getProps();return Z0()&&s&&J0.has(s)&&!c&&!h&&!i&&r!=="mirror"&&o!==0&&l!=="inertia"}}const iy={type:"spring",stiffness:500,damping:25,restSpeed:10},ry=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),oy={type:"keyframes",duration:.8},ay={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ly=(e,{keyframes:t})=>t.length>2?oy:is.has(e)?e.startsWith("scale")?ry(t[1]):iy:ay;function cy({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:l,from:c,elapsed:h,...a}){return!!Object.keys(a).length}const ml=(e,t,n,s={},i,r)=>o=>{const l=Za(s,e)||{},c=l.delay||s.delay||0;let{elapsed:h=0}=s;h=h-Qe(c);let a={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-h,onUpdate:f=>{t.set(f),l.onUpdate&&l.onUpdate(f)},onComplete:()=>{o(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:r?void 0:i};cy(l)||(a={...a,...ly(e,a)}),a.duration&&(a.duration=Qe(a.duration)),a.repeatDelay&&(a.repeatDelay=Qe(a.repeatDelay)),a.from!==void 0&&(a.keyframes[0]=a.from);let u=!1;if((a.type===!1||a.duration===0&&!a.repeatDelay)&&(a.duration=0,a.delay===0&&(u=!0)),u&&!r&&t.get()!==void 0){const f=Gr(a.keyframes,l);if(f!==void 0)return Bt.update(()=>{a.onUpdate(f),a.onComplete()}),new Ag([])}return!r&&jc.supports(a)?new jc(a):new fl(a)};function hy({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function rf(e,t,{delay:n=0,transitionOverride:s,type:i}={}){var r;let{transition:o=e.getDefaultTransition(),transitionEnd:l,...c}=t;s&&(o=s);const h=[],a=i&&e.animationState&&e.animationState.getState()[i];for(const u in c){const f=e.getValue(u,(r=e.latestValues[u])!==null&&r!==void 0?r:null),p=c[u];if(p===void 0||a&&hy(a,u))continue;const g={delay:n,...Za(o||{},u)};let d=!1;if(window.MotionHandoffAnimation){const C=Ad(e);if(C){const x=window.MotionHandoffAnimation(C,u,Bt);x!==null&&(g.startTime=x,d=!0)}}ia(e,u),f.start(ml(u,f,p,e.shouldReduceMotion&&Ed.has(u)?{type:!1}:g,e,d));const w=f.animation;w&&h.push(w)}return l&&Promise.all(h).then(()=>{Bt.update(()=>{l&&jg(e,l)})}),h}function ua(e,t,n={}){var s;const i=qr(e,t,n.type==="exit"?(s=e.presenceContext)===null||s===void 0?void 0:s.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(r=n.transitionOverride);const o=i?()=>Promise.all(rf(e,i,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(h=0)=>{const{delayChildren:a=0,staggerChildren:u,staggerDirection:f}=r;return uy(e,t,a+h,u,f,n)}:()=>Promise.resolve(),{when:c}=r;if(c){const[h,a]=c==="beforeChildren"?[o,l]:[l,o];return h().then(()=>a())}else return Promise.all([o(),l(n.delay)])}function uy(e,t,n=0,s=0,i=1,r){const o=[],l=(e.variantChildren.size-1)*s,c=i===1?(h=0)=>h*s:(h=0)=>l-h*s;return Array.from(e.variantChildren).sort(dy).forEach((h,a)=>{h.notify("AnimationStart",t),o.push(ua(h,t,{...r,delay:n+c(a)}).then(()=>h.notify("AnimationComplete",t)))}),Promise.all(o)}function dy(e,t){return e.sortNodePosition(t)}function fy(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const i=t.map(r=>ua(e,r,n));s=Promise.all(i)}else if(typeof t=="string")s=ua(e,t,n);else{const i=typeof t=="function"?qr(e,t,n.custom):t;s=Promise.all(rf(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}const my=Va.length;function of(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?of(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<my;n++){const s=Va[n],i=e.props[s];(Ei(i)||i===!1)&&(t[s]=i)}return t}const py=[...Wa].reverse(),gy=Wa.length;function yy(e){return t=>Promise.all(t.map(({animation:n,options:s})=>fy(e,n,s)))}function by(e){let t=yy(e),n=Oc(),s=!0;const i=c=>(h,a)=>{var u;const f=qr(e,a,c==="exit"?(u=e.presenceContext)===null||u===void 0?void 0:u.custom:void 0);if(f){const{transition:p,transitionEnd:g,...d}=f;h={...h,...d,...g}}return h};function r(c){t=c(e)}function o(c){const{props:h}=e,a=of(e.parent)||{},u=[],f=new Set;let p={},g=1/0;for(let w=0;w<gy;w++){const C=py[w],x=n[C],k=h[C]!==void 0?h[C]:a[C],S=Ei(k),T=C===c?x.isActive:null;T===!1&&(g=w);let P=k===a[C]&&k!==h[C]&&S;if(P&&s&&e.manuallyAnimateOnMount&&(P=!1),x.protectedKeys={...p},!x.isActive&&T===null||!k&&!x.prevProp||Ur(k)||typeof k=="boolean")continue;const I=vy(x.prevProp,k);let L=I||C===c&&x.isActive&&!P&&S||w>g&&S,O=!1;const H=Array.isArray(k)?k:[k];let U=H.reduce(i(C),{});T===!1&&(U={});const{prevResolvedValues:q={}}=x,X={...q,...U},V=J=>{L=!0,f.has(J)&&(O=!0,f.delete(J)),x.needsAnimating[J]=!0;const nt=e.getValue(J);nt&&(nt.liveStyle=!1)};for(const J in X){const nt=U[J],it=q[J];if(p.hasOwnProperty(J))continue;let Q=!1;ea(nt)&&ea(it)?Q=!bd(nt,it):Q=nt!==it,Q?nt!=null?V(J):f.add(J):nt!==void 0&&f.has(J)?V(J):x.protectedKeys[J]=!0}x.prevProp=k,x.prevResolvedValues=U,x.isActive&&(p={...p,...U}),s&&e.blockInitialAnimation&&(L=!1),L&&(!(P&&I)||O)&&u.push(...H.map(J=>({animation:J,options:{type:C}})))}if(f.size){const w={};f.forEach(C=>{const x=e.getBaseTarget(C),k=e.getValue(C);k&&(k.liveStyle=!0),w[C]=x??null}),u.push({animation:w})}let d=!!u.length;return s&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(d=!1),s=!1,d?t(u):Promise.resolve()}function l(c,h){var a;if(n[c].isActive===h)return Promise.resolve();(a=e.variantChildren)===null||a===void 0||a.forEach(f=>{var p;return(p=f.animationState)===null||p===void 0?void 0:p.setActive(c,h)}),n[c].isActive=h;const u=o(c);for(const f in n)n[f].protectedKeys={};return u}return{animateChanges:o,setActive:l,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Oc(),s=!0}}}function vy(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!bd(t,e):!1}function Hn(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Oc(){return{animate:Hn(!0),whileInView:Hn(),whileHover:Hn(),whileTap:Hn(),whileDrag:Hn(),whileFocus:Hn(),exit:Hn()}}class _n{constructor(t){this.isMounted=!1,this.node=t}update(){}}class xy extends _n{constructor(t){super(t),t.animationState||(t.animationState=by(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ur(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let wy=0;class Sy extends _n{constructor(){super(...arguments),this.id=wy++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const Cy={animation:{Feature:xy},exit:{Feature:Sy}};function Pi(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function zi(e){return{point:{x:e.pageX,y:e.pageY}}}const ky=e=>t=>nl(t)&&e(t,zi(t));function yi(e,t,n,s){return Pi(e,t,ky(n),s)}const Uc=(e,t)=>Math.abs(e-t);function My(e,t){const n=Uc(e.x,t.x),s=Uc(e.y,t.y);return Math.sqrt(n**2+s**2)}class af{constructor(t,n,{transformPagePoint:s,contextWindow:i,dragSnapToOrigin:r=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const u=ko(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,p=My(u.offset,{x:0,y:0})>=3;if(!f&&!p)return;const{point:g}=u,{timestamp:d}=me;this.history.push({...g,timestamp:d});const{onStart:w,onMove:C}=this.handlers;f||(w&&w(this.lastMoveEvent,u),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,u)},this.handlePointerMove=(u,f)=>{this.lastMoveEvent=u,this.lastMoveEventInfo=Co(f,this.transformPagePoint),Bt.update(this.updatePoint,!0)},this.handlePointerUp=(u,f)=>{this.end();const{onEnd:p,onSessionEnd:g,resumeAnimation:d}=this.handlers;if(this.dragSnapToOrigin&&d&&d(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=ko(u.type==="pointercancel"?this.lastMoveEventInfo:Co(f,this.transformPagePoint),this.history);this.startEvent&&p&&p(u,w),g&&g(u,w)},!nl(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.contextWindow=i||window;const o=zi(t),l=Co(o,this.transformPagePoint),{point:c}=l,{timestamp:h}=me;this.history=[{...c,timestamp:h}];const{onSessionStart:a}=n;a&&a(t,ko(l,this.history)),this.removeListeners=Li(yi(this.contextWindow,"pointermove",this.handlePointerMove),yi(this.contextWindow,"pointerup",this.handlePointerUp),yi(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),An(this.updatePoint)}}function Co(e,t){return t?{point:t(e.point)}:e}function Hc(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ko({point:e},t){return{point:e,delta:Hc(e,lf(t)),offset:Hc(e,Ey(t)),velocity:Ty(t,.1)}}function Ey(e){return e[0]}function lf(e){return e[e.length-1]}function Ty(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=lf(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>Qe(t)));)n--;if(!s)return{x:0,y:0};const r=hn(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}const cf=1e-4,Ay=1-cf,Ry=1+cf,hf=.01,Py=0-hf,_y=0+hf;function Ne(e){return e.max-e.min}function $y(e,t,n){return Math.abs(e-t)<=n}function qc(e,t,n,s=.5){e.origin=s,e.originPoint=Ht(t.min,t.max,e.origin),e.scale=Ne(n)/Ne(t),e.translate=Ht(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Ay&&e.scale<=Ry||isNaN(e.scale))&&(e.scale=1),(e.translate>=Py&&e.translate<=_y||isNaN(e.translate))&&(e.translate=0)}function bi(e,t,n,s){qc(e.x,t.x,n.x,s?s.originX:void 0),qc(e.y,t.y,n.y,s?s.originY:void 0)}function Gc(e,t,n){e.min=n.min+t.min,e.max=e.min+Ne(t)}function Ny(e,t,n){Gc(e.x,t.x,n.x),Gc(e.y,t.y,n.y)}function Yc(e,t,n){e.min=t.min-n.min,e.max=e.min+Ne(t)}function vi(e,t,n){Yc(e.x,t.x,n.x),Yc(e.y,t.y,n.y)}function Iy(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?Ht(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?Ht(n,e,s.max):Math.min(e,n)),e}function Xc(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Dy(e,{top:t,left:n,bottom:s,right:i}){return{x:Xc(e.x,n,i),y:Xc(e.y,t,s)}}function Qc(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function Ly(e,t){return{x:Qc(e.x,t.x),y:Qc(e.y,t.y)}}function zy(e,t){let n=.5;const s=Ne(e),i=Ne(t);return i>s?n=zs(t.min,t.max-s,e.min):s>i&&(n=zs(e.min,e.max-i,t.min)),un(0,1,n)}function Fy(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const da=.35;function By(e=da){return e===!1?e=0:e===!0&&(e=da),{x:Jc(e,"left","right"),y:Jc(e,"top","bottom")}}function Jc(e,t,n){return{min:Kc(e,t),max:Kc(e,n)}}function Kc(e,t){return typeof e=="number"?e:e[t]||0}const Zc=()=>({translate:0,scale:1,origin:0,originPoint:0}),Rs=()=>({x:Zc(),y:Zc()}),th=()=>({min:0,max:0}),Kt=()=>({x:th(),y:th()});function Fe(e){return[e("x"),e("y")]}function uf({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Wy({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Vy(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Mo(e){return e===void 0||e===1}function fa({scale:e,scaleX:t,scaleY:n}){return!Mo(e)||!Mo(t)||!Mo(n)}function Yn(e){return fa(e)||df(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function df(e){return eh(e.x)||eh(e.y)}function eh(e){return e&&e!=="0%"}function $r(e,t,n){const s=e-n,i=t*s;return n+i}function nh(e,t,n,s,i){return i!==void 0&&(e=$r(e,i,s)),$r(e,n,s)+t}function ma(e,t=0,n=1,s,i){e.min=nh(e.min,t,n,s,i),e.max=nh(e.max,t,n,s,i)}function ff(e,{x:t,y:n}){ma(e.x,t.translate,t.scale,t.originPoint),ma(e.y,n.translate,n.scale,n.originPoint)}const sh=.999999999999,ih=1.0000000000001;function jy(e,t,n,s=!1){const i=n.length;if(!i)return;t.x=t.y=1;let r,o;for(let l=0;l<i;l++){r=n[l],o=r.projectionDelta;const{visualElement:c}=r.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&_s(e,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,ff(e,o)),s&&Yn(r.latestValues)&&_s(e,r.latestValues))}t.x<ih&&t.x>sh&&(t.x=1),t.y<ih&&t.y>sh&&(t.y=1)}function Ps(e,t){e.min=e.min+t,e.max=e.max+t}function rh(e,t,n,s,i=.5){const r=Ht(e.min,e.max,i);ma(e,t,n,r,s)}function _s(e,t){rh(e.x,t.x,t.scaleX,t.scale,t.originX),rh(e.y,t.y,t.scaleY,t.scale,t.originY)}function mf(e,t){return uf(Vy(e.getBoundingClientRect(),t))}function Oy(e,t,n){const s=mf(e,n),{scroll:i}=t;return i&&(Ps(s.x,i.offset.x),Ps(s.y,i.offset.y)),s}const pf=({current:e})=>e?e.ownerDocument.defaultView:null,Uy=new WeakMap;class Hy{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Kt(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const i=a=>{const{dragSnapToOrigin:u}=this.getProps();u?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(zi(a).point)},r=(a,u)=>{const{drag:f,dragPropagation:p,onDragStart:g}=this.getProps();if(f&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=zg(f),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Fe(w=>{let C=this.getAxisMotionValue(w).get()||0;if(Je.test(C)){const{projection:x}=this.visualElement;if(x&&x.layout){const k=x.layout.layoutBox[w];k&&(C=Ne(k)*(parseFloat(C)/100))}}this.originPoint[w]=C}),g&&Bt.postRender(()=>g(a,u)),ia(this.visualElement,"transform");const{animationState:d}=this.visualElement;d&&d.setActive("whileDrag",!0)},o=(a,u)=>{const{dragPropagation:f,dragDirectionLock:p,onDirectionLock:g,onDrag:d}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:w}=u;if(p&&this.currentDirection===null){this.currentDirection=qy(w),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",u.point,w),this.updateAxis("y",u.point,w),this.visualElement.render(),d&&d(a,u)},l=(a,u)=>this.stop(a,u),c=()=>Fe(a=>{var u;return this.getAnimationState(a)==="paused"&&((u=this.getAxisMotionValue(a).animation)===null||u===void 0?void 0:u.play())}),{dragSnapToOrigin:h}=this.getProps();this.panSession=new af(t,{onSessionStart:i,onStart:r,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,contextWindow:pf(this.visualElement)})}stop(t,n){const s=this.isDragging;if(this.cancel(),!s)return;const{velocity:i}=n;this.startAnimation(i);const{onDragEnd:r}=this.getProps();r&&Bt.postRender(()=>r(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:i}=this.getProps();if(!s||!tr(t,i,this.currentDirection))return;const r=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=Iy(o,this.constraints[t],this.elastic[t])),r.set(o)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:s}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,r=this.constraints;n&&Ts(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&i?this.constraints=Dy(i.layoutBox,n):this.constraints=!1,this.elastic=By(s),r!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Fe(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Fy(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!Ts(t))return!1;const s=t.current;Tn(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=Oy(s,i.root,this.visualElement.getTransformPagePoint());let o=Ly(i.layout.layoutBox,r);if(n){const l=n(Wy(o));this.hasMutatedConstraints=!!l,l&&(o=uf(l))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},h=Fe(a=>{if(!tr(a,n,this.currentDirection))return;let u=c&&c[a]||{};o&&(u={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,g={type:"inertia",velocity:s?t[a]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...r,...u};return this.startAxisValueAnimation(a,g)});return Promise.all(h).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ia(this.visualElement,t),s.start(ml(t,s,0,n,this.visualElement,!1))}stopAnimation(){Fe(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Fe(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){Fe(n=>{const{drag:s}=this.getProps();if(!tr(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:l}=i.layout.layoutBox[n];r.set(t[n]-Ht(o,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Ts(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Fe(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();i[o]=zy({min:c,max:c},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Fe(o=>{if(!tr(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:h}=this.constraints[o];l.set(Ht(c,h,i[o]))})}addListeners(){if(!this.visualElement.current)return;Uy.set(this.visualElement,this);const t=this.visualElement.current,n=yi(t,"pointerdown",c=>{const{drag:h,dragListener:a=!0}=this.getProps();h&&a&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Ts(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Bt.read(s);const o=Pi(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:h})=>{this.isDragging&&h&&(Fe(a=>{const u=this.getAxisMotionValue(a);u&&(this.originPoint[a]+=c[a].translate,u.set(u.get()+c[a].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=da,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:l}}}function tr(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function qy(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Gy extends _n{constructor(t){super(t),this.removeGroupControls=Ae,this.removeListeners=Ae,this.controls=new Hy(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ae}unmount(){this.removeGroupControls(),this.removeListeners()}}const oh=e=>(t,n)=>{e&&Bt.postRender(()=>e(t,n))};class Yy extends _n{constructor(){super(...arguments),this.removePointerDownListener=Ae}onPointerDown(t){this.session=new af(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:pf(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:oh(t),onStart:oh(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&Bt.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=yi(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vr={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ah(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const oi={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(ct.test(e))e=parseFloat(e);else return e;const n=ah(e,t.target.x),s=ah(e,t.target.y);return`${n}% ${s}%`}},Xy={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=Rn.parse(e);if(i.length>5)return s;const r=Rn.createTransformer(e),o=typeof i[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=l,i[1+o]/=c;const h=Ht(l,c,.5);return typeof i[2+o]=="number"&&(i[2+o]/=h),typeof i[3+o]=="number"&&(i[3+o]/=h),r(i)}};class Qy extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=t;gg(Jy),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),vr.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,o=s.projection;return o&&(o.isPresent=r,i||t.layoutDependency!==n||n===void 0?o.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?o.promote():o.relegate()||Bt.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Oa.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function gf(e){const[t,n]=Ku(),s=m.useContext(Da);return cn.jsx(Qy,{...e,layoutGroup:s,switchLayoutGroup:m.useContext(rd),isPresent:t,safeToRemove:n})}const Jy={borderRadius:{...oi,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:oi,borderTopRightRadius:oi,borderBottomLeftRadius:oi,borderBottomRightRadius:oi,boxShadow:Xy};function Ky(e,t,n){const s=ve(e)?e:Ai(e);return s.start(ml("",s,t,n)),s.animation}function Zy(e){return e instanceof SVGElement&&e.tagName!=="svg"}const tb=(e,t)=>e.depth-t.depth;class eb{constructor(){this.children=[],this.isDirty=!1}add(t){sl(this.children,t),this.isDirty=!0}remove(t){il(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(tb),this.isDirty=!1,this.children.forEach(t)}}function nb(e,t){const n=Ke.now(),s=({timestamp:i})=>{const r=i-n;r>=t&&(An(s),e(r-t))};return Bt.read(s,!0),()=>An(s)}const yf=["TopLeft","TopRight","BottomLeft","BottomRight"],sb=yf.length,lh=e=>typeof e=="string"?parseFloat(e):e,ch=e=>typeof e=="number"||ct.test(e);function ib(e,t,n,s,i,r){i?(e.opacity=Ht(0,n.opacity!==void 0?n.opacity:1,rb(s)),e.opacityExit=Ht(t.opacity!==void 0?t.opacity:1,0,ob(s))):r&&(e.opacity=Ht(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,s));for(let o=0;o<sb;o++){const l=`border${yf[o]}Radius`;let c=hh(t,l),h=hh(n,l);if(c===void 0&&h===void 0)continue;c||(c=0),h||(h=0),c===0||h===0||ch(c)===ch(h)?(e[l]=Math.max(Ht(lh(c),lh(h),s),0),(Je.test(h)||Je.test(c))&&(e[l]+="%")):e[l]=h}(t.rotate||n.rotate)&&(e.rotate=Ht(t.rotate||0,n.rotate||0,s))}function hh(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const rb=bf(0,.5,Dd),ob=bf(.5,.95,Ae);function bf(e,t,n){return s=>s<e?0:s>t?1:n(zs(e,t,s))}function uh(e,t){e.min=t.min,e.max=t.max}function ze(e,t){uh(e.x,t.x),uh(e.y,t.y)}function dh(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function fh(e,t,n,s,i){return e-=t,e=$r(e,1/n,s),i!==void 0&&(e=$r(e,1/i,s)),e}function ab(e,t=0,n=1,s=.5,i,r=e,o=e){if(Je.test(t)&&(t=parseFloat(t),t=Ht(o.min,o.max,t/100)-o.min),typeof t!="number")return;let l=Ht(r.min,r.max,s);e===r&&(l-=t),e.min=fh(e.min,t,n,l,i),e.max=fh(e.max,t,n,l,i)}function mh(e,t,[n,s,i],r,o){ab(e,t[n],t[s],t[i],t.scale,r,o)}const lb=["x","scaleX","originX"],cb=["y","scaleY","originY"];function ph(e,t,n,s){mh(e.x,t,lb,n?n.x:void 0,s?s.x:void 0),mh(e.y,t,cb,n?n.y:void 0,s?s.y:void 0)}function gh(e){return e.translate===0&&e.scale===1}function vf(e){return gh(e.x)&&gh(e.y)}function yh(e,t){return e.min===t.min&&e.max===t.max}function hb(e,t){return yh(e.x,t.x)&&yh(e.y,t.y)}function bh(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function xf(e,t){return bh(e.x,t.x)&&bh(e.y,t.y)}function vh(e){return Ne(e.x)/Ne(e.y)}function xh(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class ub{constructor(){this.members=[]}add(t){sl(this.members,t),t.scheduleRender()}remove(t){if(il(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function db(e,t,n){let s="";const i=e.x.translate/t.x,r=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:h,rotate:a,rotateX:u,rotateY:f,skewX:p,skewY:g}=n;h&&(s=`perspective(${h}px) ${s}`),a&&(s+=`rotate(${a}deg) `),u&&(s+=`rotateX(${u}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}deg) `),g&&(s+=`skewY(${g}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(s+=`scale(${l}, ${c})`),s||"none"}const Xn={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},di=typeof window<"u"&&window.MotionDebug!==void 0,Eo=["","X","Y","Z"],fb={visibility:"hidden"},wh=1e3;let mb=0;function To(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function wf(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Ad(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Bt,!(i||r))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&wf(s)}function Sf({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},l=t==null?void 0:t()){this.id=mb++,this.animationId=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.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,di&&(Xn.totalNodes=Xn.resolvedTargetDeltas=Xn.recalculatedProjection=0),this.nodes.forEach(yb),this.nodes.forEach(Sb),this.nodes.forEach(Cb),this.nodes.forEach(bb),di&&window.MotionDebug.record(Xn)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new eb)}addEventListener(o,l){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new rl),this.eventHandlers.get(o).add(l)}notifyListeners(o,...l){const c=this.eventHandlers.get(o);c&&c.notify(...l)}hasListeners(o){return this.eventHandlers.has(o)}mount(o,l=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=Zy(o),this.instance=o;const{layoutId:c,layout:h,visualElement:a}=this.options;if(a&&!a.current&&a.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),l&&(h||c)&&(this.isLayoutDirty=!0),e){let u;const f=()=>this.root.updateBlockedByResize=!1;e(o,()=>{this.root.updateBlockedByResize=!0,u&&u(),u=nb(f,250),vr.hasAnimatedSinceResize&&(vr.hasAnimatedSinceResize=!1,this.nodes.forEach(Ch))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&a&&(c||h)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:f,hasRelativeTargetChanged:p,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const d=this.options.transition||a.getDefaultTransition()||Ab,{onLayoutAnimationStart:w,onLayoutAnimationComplete:C}=a.getProps(),x=!this.targetLayout||!xf(this.targetLayout,g)||p,k=!f&&p;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||k||f&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(u,k);const S={...Za(d,"layout"),onPlay:w,onComplete:C};(a.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S)}else f||Ch(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,An(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(kb),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&wf(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let a=0;a<this.path.length;a++){const u=this.path[a];u.shouldResetTransform=!0,u.updateScroll("snapshot"),u.options.layoutRoot&&u.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Sh);return}this.isUpdating||this.nodes.forEach(xb),this.isUpdating=!1,this.nodes.forEach(wb),this.nodes.forEach(pb),this.nodes.forEach(gb),this.clearAllSnapshots();const l=Ke.now();me.delta=un(0,1e3/60,l-me.timestamp),me.timestamp=l,me.isProcessing=!0,yo.update.process(me),yo.preRender.process(me),yo.render.process(me),me.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Oa.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(vb),this.sharedNodes.forEach(Mb)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Bt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Bt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Kt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(l=!1),l){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!vf(this.projectionDelta),c=this.getTransformTemplate(),h=c?c(this.latestValues,""):void 0,a=h!==this.prevTransformTemplateValue;o&&(l||Yn(this.latestValues)||a)&&(i(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return o&&(c=this.removeTransform(c)),Rb(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var o;const{visualElement:l}=this.options;if(!l)return Kt();const c=l.measureViewportBox();if(!(((o=this.scroll)===null||o===void 0?void 0:o.wasRoot)||this.path.some(Pb))){const{scroll:a}=this.root;a&&(Ps(c.x,a.offset.x),Ps(c.y,a.offset.y))}return c}removeElementScroll(o){var l;const c=Kt();if(ze(c,o),!((l=this.scroll)===null||l===void 0)&&l.wasRoot)return c;for(let h=0;h<this.path.length;h++){const a=this.path[h],{scroll:u,options:f}=a;a!==this.root&&u&&f.layoutScroll&&(u.wasRoot&&ze(c,o),Ps(c.x,u.offset.x),Ps(c.y,u.offset.y))}return c}applyTransform(o,l=!1){const c=Kt();ze(c,o);for(let h=0;h<this.path.length;h++){const a=this.path[h];!l&&a.options.layoutScroll&&a.scroll&&a!==a.root&&_s(c,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),Yn(a.latestValues)&&_s(c,a.latestValues)}return Yn(this.latestValues)&&_s(c,this.latestValues),c}removeTransform(o){const l=Kt();ze(l,o);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!h.instance||!Yn(h.latestValues))continue;fa(h.latestValues)&&h.updateSnapshot();const a=Kt(),u=h.measurePageBox();ze(a,u),ph(l,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,a)}return Yn(this.latestValues)&&ph(l,this.latestValues),l}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}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!==me.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var l;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const h=!!this.resumingFrom||this!==c;if(!(o||h&&this.isSharedProjectionDirty||this.isProjectionDirty||!((l=this.parent)===null||l===void 0)&&l.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:f}=this.options;if(!(!this.layout||!(u||f))){if(this.resolvedRelativeTargetAt=me.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Kt(),this.relativeTargetOrigin=Kt(),vi(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),ze(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Kt(),this.targetWithTransforms=Kt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ny(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ze(this.target,this.layout.layoutBox),ff(this.target,this.targetDelta)):ze(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Kt(),this.relativeTargetOrigin=Kt(),vi(this.relativeTargetOrigin,this.target,p.target),ze(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}di&&Xn.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||fa(this.parent.latestValues)||df(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var o;const l=this.getLead(),c=!!this.resumingFrom||this!==l;let h=!0;if((this.isProjectionDirty||!((o=this.parent)===null||o===void 0)&&o.isProjectionDirty)&&(h=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(h=!1),this.resolvedRelativeTargetAt===me.timestamp&&(h=!1),h)return;const{layout:a,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(a||u))return;ze(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,p=this.treeScale.y;jy(this.layoutCorrected,this.treeScale,this.path,c),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=Kt());const{target:g}=l;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(dh(this.prevProjectionDelta.x,this.projectionDelta.x),dh(this.prevProjectionDelta.y,this.projectionDelta.y)),bi(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==p||!xh(this.projectionDelta.x,this.prevProjectionDelta.x)||!xh(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g)),di&&Xn.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var l;if((l=this.options.visualElement)===null||l===void 0||l.scheduleRender(),o){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Rs(),this.projectionDelta=Rs(),this.projectionDeltaWithTransform=Rs()}setAnimationOrigin(o,l=!1){const c=this.snapshot,h=c?c.latestValues:{},a={...this.latestValues},u=Rs();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const f=Kt(),p=c?c.source:void 0,g=this.layout?this.layout.source:void 0,d=p!==g,w=this.getStack(),C=!w||w.members.length<=1,x=!!(d&&!C&&this.options.crossfade===!0&&!this.path.some(Tb));this.animationProgress=0;let k;this.mixTargetDelta=S=>{const T=S/1e3;kh(u.x,o.x,T),kh(u.y,o.y,T),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(vi(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Eb(this.relativeTarget,this.relativeTargetOrigin,f,T),k&&hb(this.relativeTarget,k)&&(this.isProjectionDirty=!1),k||(k=Kt()),ze(k,this.relativeTarget)),d&&(this.animationValues=a,ib(a,h,this.latestValues,T,x,C)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=T},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(An(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Bt.update(()=>{vr.hasAnimatedSinceResize=!0,this.currentAnimation=Ky(0,wh,{...o,onUpdate:l=>{this.mixTargetDelta(l),o.onUpdate&&o.onUpdate(l)},onComplete:()=>{o.onComplete&&o.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);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(wh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:l,target:c,layout:h,latestValues:a}=o;if(!(!l||!c||!h)){if(this!==o&&this.layout&&h&&Cf(this.options.animationType,this.layout.layoutBox,h.layoutBox)){c=this.target||Kt();const u=Ne(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+u;const f=Ne(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+f}ze(l,c),_s(l,a),bi(this.projectionDeltaWithTransform,this.layoutCorrected,l,a)}}registerSharedNode(o,l){this.sharedNodes.has(o)||this.sharedNodes.set(o,new ub),this.sharedNodes.get(o).add(l);const h=l.options.initialPromotionConfig;l.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(l):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:l}=this.options;return l?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:l}=this.options;return l?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:l,preserveFollowOpacity:c}={}){const h=this.getStack();h&&h.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let l=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const h={};c.z&&To("z",o,h,this.animationValues);for(let a=0;a<Eo.length;a++)To(`rotate${Eo[a]}`,o,h,this.animationValues),To(`skew${Eo[a]}`,o,h,this.animationValues);o.render();for(const a in h)o.setStaticValue(a,h[a]),this.animationValues&&(this.animationValues[a]=h[a]);o.scheduleRender()}getProjectionStyles(o){var l,c;if(!this.instance||this.isSVG)return;if(!this.isVisible)return fb;const h={visibility:""},a=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,h.opacity="",h.pointerEvents=yr(o==null?void 0:o.pointerEvents)||"",h.transform=a?a(this.latestValues,""):"none",h;const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){const d={};return this.options.layoutId&&(d.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,d.pointerEvents=yr(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Yn(this.latestValues)&&(d.transform=a?a({},""):"none",this.hasProjected=!1),d}const f=u.animationValues||u.latestValues;this.applyTransformsToTarget(),h.transform=db(this.projectionDeltaWithTransform,this.treeScale,f),a&&(h.transform=a(f,h.transform));const{x:p,y:g}=this.projectionDelta;h.transformOrigin=`${p.origin*100}% ${g.origin*100}% 0`,u.animationValues?h.opacity=u===this?(c=(l=f.opacity)!==null&&l!==void 0?l:this.latestValues.opacity)!==null&&c!==void 0?c:1:this.preserveOpacity?this.latestValues.opacity:f.opacityExit:h.opacity=u===this?f.opacity!==void 0?f.opacity:"":f.opacityExit!==void 0?f.opacityExit:0;for(const d in Tr){if(f[d]===void 0)continue;const{correct:w,applyTo:C}=Tr[d],x=h.transform==="none"?f[d]:w(f[d],u);if(C){const k=C.length;for(let S=0;S<k;S++)h[C[S]]=x}else h[d]=x}return this.options.layoutId&&(h.pointerEvents=u===this?yr(o==null?void 0:o.pointerEvents)||"":"none"),h}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var l;return(l=o.currentAnimation)===null||l===void 0?void 0:l.stop()}),this.root.nodes.forEach(Sh),this.root.sharedNodes.clear()}}}function pb(e){e.updateLayout()}function gb(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:s,measuredBox:i}=e.layout,{animationType:r}=e.options,o=n.source!==e.layout.source;r==="size"?Fe(u=>{const f=o?n.measuredBox[u]:n.layoutBox[u],p=Ne(f);f.min=s[u].min,f.max=f.min+p}):Cf(r,n.layoutBox,s)&&Fe(u=>{const f=o?n.measuredBox[u]:n.layoutBox[u],p=Ne(s[u]);f.max=f.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+p)});const l=Rs();bi(l,s,n.layoutBox);const c=Rs();o?bi(c,e.applyTransform(i,!0),n.measuredBox):bi(c,s,n.layoutBox);const h=!vf(l);let a=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:f,layout:p}=u;if(f&&p){const g=Kt();vi(g,n.layoutBox,f.layoutBox);const d=Kt();vi(d,s,p.layoutBox),xf(g,d)||(a=!0),u.options.layoutRoot&&(e.relativeTarget=d,e.relativeTargetOrigin=g,e.relativeParent=u)}}}e.notifyListeners("didUpdate",{layout:s,snapshot:n,delta:c,layoutDelta:l,hasLayoutChanged:h,hasRelativeTargetChanged:a})}else if(e.isLead()){const{onExitComplete:s}=e.options;s&&s()}e.options.transition=void 0}function yb(e){di&&Xn.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function bb(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function vb(e){e.clearSnapshot()}function Sh(e){e.clearMeasurements()}function xb(e){e.isLayoutDirty=!1}function wb(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Ch(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Sb(e){e.resolveTargetDelta()}function Cb(e){e.calcProjection()}function kb(e){e.resetSkewAndRotation()}function Mb(e){e.removeLeadSnapshot()}function kh(e,t,n){e.translate=Ht(t.translate,0,n),e.scale=Ht(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Mh(e,t,n,s){e.min=Ht(t.min,n.min,s),e.max=Ht(t.max,n.max,s)}function Eb(e,t,n,s){Mh(e.x,t.x,n.x,s),Mh(e.y,t.y,n.y,s)}function Tb(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Ab={duration:.45,ease:[.4,0,.1,1]},Eh=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Th=Eh("applewebkit/")&&!Eh("chrome/")?Math.round:Ae;function Ah(e){e.min=Th(e.min),e.max=Th(e.max)}function Rb(e){Ah(e.x),Ah(e.y)}function Cf(e,t,n){return e==="position"||e==="preserve-aspect"&&!$y(vh(t),vh(n),.2)}function Pb(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const _b=Sf({attachResizeListener:(e,t)=>Pi(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Ao={current:void 0},kf=Sf({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Ao.current){const e=new _b({});e.mount(window),e.setOptions({layoutScroll:!0}),Ao.current=e}return Ao.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),$b={pan:{Feature:Yy},drag:{Feature:Gy,ProjectionNode:kf,MeasureLayout:gf}};function Rh(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&Bt.postRender(()=>r(t,zi(t)))}class Nb extends _n{mount(){const{current:t}=this.node;t&&(this.unmount=$g(t,n=>(Rh(this.node,n,"Start"),s=>Rh(this.node,s,"End"))))}unmount(){}}class Ib extends _n{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=Li(Pi(this.node.current,"focus",()=>this.onFocus()),Pi(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ph(e,t,n){const{props:s}=e;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&Bt.postRender(()=>r(t,zi(t)))}class Db extends _n{mount(){const{current:t}=this.node;t&&(this.unmount=Lg(t,n=>(Ph(this.node,n,"Start"),(s,{success:i})=>Ph(this.node,s,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const pa=new WeakMap,Ro=new WeakMap,Lb=e=>{const t=pa.get(e.target);t&&t(e)},zb=e=>{e.forEach(Lb)};function Fb({root:e,...t}){const n=e||document;Ro.has(n)||Ro.set(n,{});const s=Ro.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(zb,{root:e,...t})),s[i]}function Bb(e,t,n){const s=Fb(t);return pa.set(e,n),s.observe(e),()=>{pa.delete(e),s.unobserve(e)}}const Wb={some:0,all:1};class Vb extends _n{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Wb[i]},l=c=>{const{isIntersecting:h}=c;if(this.isInView===h||(this.isInView=h,r&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:a,onViewportLeave:u}=this.node.getProps(),f=h?a:u;f&&f(c)};return Bb(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(jb(t,n))&&this.startObserver()}unmount(){}}function jb({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Ob={inView:{Feature:Vb},tap:{Feature:Db},focus:{Feature:Ib},hover:{Feature:Nb}},Ub={layout:{ProjectionNode:kf,MeasureLayout:gf}},ga={current:null},Mf={current:!1};function Hb(){if(Mf.current=!0,!!Fa)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>ga.current=e.matches;e.addListener(t),t()}else ga.current=!1}const qb=[...Xd,be,Rn],Gb=e=>qb.find(Yd(e)),_h=new WeakMap;function Yb(e,t,n){for(const s in t){const i=t[s],r=n[s];if(ve(i))e.addValue(s,i),process.env.NODE_ENV==="development"&&jr(i.version==="11.18.2",`Attempting to mix Motion versions ${i.version} with 11.18.2 may not work as expected.`);else if(ve(r))e.addValue(s,Ai(i,{owner:e}));else if(r!==i)if(e.hasValue(s)){const o=e.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(s);e.addValue(s,Ai(o!==void 0?o:i,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const $h=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Xb{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=ul,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=()=>{const p=Ke.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,Bt.render(this.render,!1,!0))};const{latestValues:c,renderState:h,onUpdate:a}=o;this.onUpdate=a,this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=h,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=l,this.blockInitialAnimation=!!r,this.isControllingVariants=Hr(n),this.isVariantNode=sd(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:u,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in f){const g=f[p];c[p]!==void 0&&ve(g)&&g.set(c[p],!1)}}mount(t){this.current=t,_h.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Mf.current||Hb(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ga.current,process.env.NODE_ENV!=="production"&&jr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected."),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){_h.delete(this.current),this.projection&&this.projection.unmount(),An(this.notifyUpdate),An(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=is.has(t),i=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&Bt.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0)}),r=n.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Fs){const n=Fs[t];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[t]&&i&&s(this.props)&&(this.features[t]=new i(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Kt()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<$h.length;s++){const i=$h[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=t[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=Yb(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Ai(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){var s;let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(s=this.getBaseTargetFromProps(this.props,t))!==null&&s!==void 0?s:this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(qd(i)||zd(i))?i=parseFloat(i):!Gb(i)&&Rn.test(n)&&(i=Od(t,n)),this.setBaseTarget(t,ve(i)?i.get():i)),ve(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:s}=this.props;let i;if(typeof s=="string"||typeof s=="object"){const o=Ha(this.props,s,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);o&&(i=o[t])}if(s&&i!==void 0)return i;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!ve(r)?r:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new rl),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Ef extends Xb{constructor(){super(...arguments),this.KeyframeResolver=Qd}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;ve(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Qb(e){return window.getComputedStyle(e)}class Jb extends Ef{constructor(){super(...arguments),this.type="html",this.renderInstance=dd}readValueFromInstance(t,n){if(is.has(n)){const s=hl(n);return s&&s.default||0}else{const s=Qb(t),i=(cd(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return mf(t,n)}build(t,n,s){Ya(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Ka(t,n,s)}}class Kb extends Ef{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Kt}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(is.has(n)){const s=hl(n);return s&&s.default||0}return n=fd.has(n)?n:ja(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return gd(t,n,s)}build(t,n,s){Xa(t,n,this.isSVGTag,s.transformTemplate)}renderInstance(t,n,s,i){md(t,n,s,i)}mount(t){this.isSVGTag=Ja(t.tagName),super.mount(t)}}const Zb=(e,t)=>Ua(e)?new Kb(t):new Jb(t,{allowProjection:e!==m.Fragment}),tv=Mg({...Cy,...Ob,...$b,...Ub},Zb),Nr=Wp(tv),ev={div:"div",span:"span",p:"p",hr:"hr",a:"a",strong:"strong",em:"em",del:"del",li:"li",ul:"ul",ol:"ol",form:"form",img:"img",header:"header",footer:"footer",section:"section",nav:"nav",main:"main",article:"article",aside:"aside",figure:"figure",figcaption:"figcaption",th:"th",td:"td",caption:"caption",blockquote:"blockquote",address:"address",time:"time",legend:"legend",label:"label",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",code:"code"},nv=new Set(["motion","initial","animate","exit","transition","variants","whileHover","whileTap","whileFocus","whileInView","animateLayout"]);function E(e,t,...n){const{style:s,className:i,...r}=t||{};if(r.motion){const l={};for(const h of nv)if(h in r){const a=h==="animateLayout"?"layout":h;let u=r[h];a==="transition"&&u&&typeof u=="object"&&(u={...u,repeat:Math.max(0,Number(u.repeat)||0)}),l[a]=u,delete r[h]}const c=Nr[e]||Nr.div;return m.createElement(c,{...r,className:i,style:s||{},...l},...n)}delete r.animateLayout;const o=ev[e];return o?m.createElement(o,{...r,className:i,style:s||{}},...n):m.createElement(e,{...r,className:i,style:s||{}},...n)}const sv={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Tf={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Af=["base","sm","md","lg","xl","2xl"],oe={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},er={xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem","6xl":"3.75rem","7xl":"4.5rem","8xl":"6rem","9xl":"8rem"},Nh={"1/2":"50%","1/3":"33.333333%","2/3":"66.666667%","1/4":"25%","2/4":"50%","3/4":"75%","1/5":"20%","2/5":"40%","3/5":"60%","4/5":"80%","1/6":"16.666667%","2/6":"33.333333%","3/6":"50%","4/6":"66.666667%","5/6":"83.333333%","1/12":"8.333333%","2/12":"16.666667%","3/12":"25%","4/12":"33.333333%","5/12":"41.666667%","6/12":"50%","7/12":"58.333333%","8/12":"66.666667%","9/12":"75%","10/12":"83.333333%","11/12":"91.666667%",full:"100%",auto:"auto",screen:"100vw",fit:"fit-content",max:"max-content",min:"min-content"},nr={"flex-row":"row","flex-row-reverse":"row-reverse","flex-col":"column","flex-col-reverse":"column-reverse"},sr={"items-start":"flex-start","items-end":"flex-end","items-center":"center","items-baseline":"baseline","items-stretch":"stretch"},ir={"justify-start":"flex-start","justify-end":"flex-end","justify-center":"center","justify-between":"space-between","justify-around":"space-around","justify-evenly":"space-evenly"},rr={"rounded-none":"0px","rounded-sm":"0.125rem",rounded:"0.25rem","rounded-md":"0.375rem","rounded-lg":"0.5rem","rounded-xl":"0.75rem","rounded-2xl":"1rem","rounded-3xl":"1.5rem","rounded-full":"9999px"},iv=["hidden","block","flex","grid","inline","inline-block","inline-flex"];function rv(e,t,n,s){const i=new Map,r=e.split(/\s+/).filter(Boolean);for(const o of r){const l=new RegExp(n.source).exec(o);if(l){i.set(l[1],s(l));continue}const c=new RegExp(t.source).exec(o);c&&i.set("base",s([null,null,c[1]]))}return i}function Rf(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(flex-row|flex-row-reverse|flex-col|flex-col-reverse)$/);if(i&&nr[i[2]]){t.set(i[1],nr[i[2]]);continue}nr[s]&&t.set("base",nr[s])}return t}function Pf(e){return rv(e,/^gap-(\d+(?:\.\d+)?)$/,/^(sm|md|lg|xl|2xl):gap-(\d+(?:\.\d+)?)$/,t=>oe[t[2]]||`${t[2]}px`)}function _f(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):w-(.+)$/);if(i){const o=Nh[i[2]]||oe[i[2]]||i[2];o&&t.set(i[1],o);continue}const r=s.match(/^w-(.+)$/);if(r){const o=Nh[r[1]]||oe[r[1]]||r[1];o&&t.set("base",o)}}return t}function $f(e){const t=new Map,n=new Map,s=new Map,i=new Map,r=new Map,o=new Map,l=new Map,c=e.split(/\s+/).filter(Boolean);for(const h of c)for(const[a,u]of[["m-",t],["mt-",n],["mr-",s],["mb-",i],["ml-",r],["mx-",o],["my-",l]]){const f=h.match(new RegExp(`^(sm|md|lg|xl|2xl):${a}(\\d+(?:\\.\\d+)?)$`));if(f&&oe[f[2]]){u.set(f[1],oe[f[2]]);break}const p=h.match(new RegExp(`^${a}(\\d+(?:\\.\\d+)?)$`));if(p&&oe[p[1]]){u.set("base",oe[p[1]]);break}}return{all:t,t:n,r:s,b:i,l:r,x:o,y:l}}function Nf(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(items-start|items-end|items-center|items-baseline|items-stretch)$/);if(i&&sr[i[2]]){t.set(i[1],sr[i[2]]);continue}sr[s]&&t.set("base",sr[s])}return t}function If(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(justify-start|justify-end|justify-center|justify-between|justify-around|justify-evenly)$/);if(i&&ir[i[2]]){t.set(i[1],ir[i[2]]);continue}ir[s]&&t.set("base",ir[s])}return t}function Df(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(rounded-none|rounded-sm|rounded|rounded-md|rounded-lg|rounded-xl|rounded-2xl|rounded-3xl|rounded-full)$/);if(i&&rr[i[2]]){t.set(i[1],rr[i[2]]);continue}rr[s]&&t.set("base",rr[s])}return t}function pl(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(hidden|block|flex|grid|inline|inline-block|inline-flex)$/);if(i){t.set(i[1],i[2]==="hidden"?"none":i[2]);continue}iv.includes(s)&&t.set("base",s==="hidden"?"none":s)}return t}function gl(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):grid-cols-(\d+)$/);if(i){t.set(i[1],parseInt(i[2],10));continue}const r=s.match(/^grid-cols-(\d+)$/);r&&t.set("base",parseInt(r[1],10))}return t}function yl(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);if(i&&er[i[2]]){t.set(i[1],er[i[2]]);continue}const r=s.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);r&&er[r[1]]&&t.set("base",er[r[1]])}return t}function bl(e){const t=new Map,n=new Map,s=new Map,i=e.split(/\s+/).filter(Boolean);for(const r of i){const o=r.match(/^(sm|md|lg|xl|2xl):px-(\d+(?:\.\d+)?)$/);if(o&&oe[o[2]]){t.set(o[1],oe[o[2]]);continue}const l=r.match(/^px-(\d+(?:\.\d+)?)$/);if(l&&oe[l[1]]){t.set("base",oe[l[1]]);continue}const c=r.match(/^(sm|md|lg|xl|2xl):py-(\d+(?:\.\d+)?)$/);if(c&&oe[c[2]]){n.set(c[1],oe[c[2]]);continue}const h=r.match(/^py-(\d+(?:\.\d+)?)$/);if(h&&oe[h[1]]){n.set("base",oe[h[1]]);continue}const a=r.match(/^(sm|md|lg|xl|2xl):p-(\d+(?:\.\d+)?)$/);if(a&&oe[a[2]]){s.set(a[1],oe[a[2]]);continue}const u=r.match(/^p-(\d+(?:\.\d+)?)$/);u&&oe[u[1]]&&s.set("base",oe[u[1]])}return{px:t,py:n,p:s}}function ya(e){return e.flexDirection.size>0||e.gap.size>0||e.width.size>0||e.alignItems.size>0||e.justifyContent.size>0||e.padding.px.size>0||e.padding.py.size>0||e.padding.p.size>0||e.display.size>0||e.gridCols.size>0||e.textSize.size>0||e.borderRadius.size>0||e.margin.all.size>0||e.margin.t.size>0||e.margin.r.size>0||e.margin.b.size>0||e.margin.l.size>0||e.margin.x.size>0||e.margin.y.size>0}function ba(e){return{flexDirection:Rf(e),gap:Pf(e),width:_f(e),margin:$f(e),alignItems:Nf(e),justifyContent:If(e),padding:bl(e),display:pl(e),gridCols:gl(e),textSize:yl(e),borderRadius:Df(e),any:!1}}const _i=sv;function ov(e){return gl(e)}function av(e,t){let n=e.get("base")??1;const s=["2xl","xl","lg","md","sm"];if(t<=0){for(const i of s)if(e.has(i))return e.get(i);return n}for(const i of["sm","md","lg","xl","2xl"])t>=(_i[i]||0)&&e.has(i)&&(n=e.get(i));return n}function vl(e){return yl(e)}function ht(e,t,n){let s=e.get("base")??n;for(const i of["sm","md","lg","xl","2xl"])t>=(_i[i]||0)&&e.has(i)&&(s=e.get(i));return s}function Fi(e){return bl(e)}function Gs(e){return pl(e)}function Lf(e){const[t,n]=m.useState(()=>{var i;return((i=e.current)==null?void 0:i.offsetWidth)??0}),s=m.useRef(t);return m.useEffect(()=>{const i=e.current;if(!i)return;const r=i.offsetWidth;r>0&&r!==s.current&&(s.current=r,n(r));const o=new ResizeObserver(l=>{for(const c of l){const h=Math.round(c.contentRect.width);h>0&&h!==s.current&&(s.current=h,n(h))}});return o.observe(i),()=>{o.disconnect()}},[e]),t}function lv(e,t,n){var h,a,u;const i=(Array.isArray(t.tabItems)?t.tabItems:Array.isArray(t.tabs)?t.tabs:[]).filter(f=>!f.condition||!e.evaluateCondition||e.evaluateCondition(f.condition));if(i.length===0)return null;const r=`__tab_${n}`,o=e.sceneData[r]??(t.defaultTab||0),l={width:"100%",display:"flex",flexDirection:"column",...t.className?((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className):{}},c=e.getCommonProps(n,l,t);return m.createElement("div",{key:n,...c},m.createElement("div",{style:{display:"flex",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,gap:"0"}},i.map((f,p)=>m.createElement("button",{key:`${n}-tab-${p}`,onClick:()=>e.setSceneData(g=>({...g,[r]:p})),style:{padding:"8px 16px",fontSize:"13px",fontWeight:o===p?600:400,color:o===p?e.cfg.colors.primary:e.cfg.colors.textMuted,borderBottom:o===p?`2px solid ${e.cfg.colors.primary}`:"2px solid transparent",background:"none",border:"none",borderBottomStyle:"solid",borderBottomWidth:"2px",borderBottomColor:o===p?e.cfg.colors.primary:"transparent",cursor:"pointer",transition:e.cfg.effects.transition}},f.label||f.title))),m.createElement("div",{style:{padding:"12px 0"}},(Array.isArray((a=i[o])==null?void 0:a.content)?i[o].content:Array.isArray((u=i[o])==null?void 0:u.children)?i[o].children:[]).map((f,p)=>e.renderComponent(f,p,`${n}-tabcontent-${o}`))))}function cv(e,t,n){var o;Array.isArray(t.items)&&!Array.isArray(t.accordionItems)&&(t.accordionItems=t.items);const s=Array.isArray(t.accordionItems)?t.accordionItems:[];if(s.length===0)return null;const i={width:"100%",display:"flex",flexDirection:"column",gap:"1px",...t.className?((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...r},s.map((l,c)=>{const h=`__acc_${n}_${c}`,a=e.sceneData[h]??(l.defaultOpen||!1);return m.createElement("div",{key:`${n}-acc-${c}`},m.createElement("button",{onClick:()=>e.setSceneData(u=>({...u,[h]:!a})),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",background:"none",border:"none",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.textSecondary,fontSize:e.cfg.typography.baseFontSize,fontWeight:500,cursor:"pointer",transition:e.cfg.effects.transition}},E("span",{style:{display:"flex",alignItems:"center",gap:"8px"}},l.icon?e.renderIcon(l.icon,14,{color:e.cfg.colors.primary}):null,E("span",null,l.title)),E("span",{style:{transform:a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s",fontSize:"24px"}},"▾")),m.createElement($p,{initial:!1},a&&m.createElement(Nr.div,{key:`${n}-acc-body-${c}`,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.3,ease:"easeInOut"},opacity:{duration:.25}},style:{overflow:"hidden"}},m.createElement("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:"8px"}},(Array.isArray(l.content)?l.content:typeof l.content=="string"?[{type:"text",text:l.content}]:Array.isArray(l.children)?l.children:[]).map((f,p)=>e.renderComponent(f,p,`${n}-acc-${c}-content`))))))}))}function hv(e,t,n){var p,g,d,w,C;const s=(p=e.paginationState)==null?void 0:p[n],i=t.pagination===!0&&s&&s.total>s.limit,r=t.pagination==="scroll",o=s?Math.ceil(s.total/s.limit):0,l=t.className||"flex flex-col gap-3 w-full",c=((g=e.parseClassNameResponsive)==null?void 0:g.call(e,l,n))??e.parseClassName(l);t.rawStyle&&Object.assign(c,t.rawStyle);const h=(d=e.loading)==null?void 0:d[n],a=(w=e.listData)==null?void 0:w[n],u=Array.isArray(a)?a:[],f=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{};return m.createElement("div",{key:n,className:l,style:c,"data-component-key":n,...f},h&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):m.createElement("div",{className:"flex justify-center py-4"},E("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),!h&&u.length===0&&t.emptyComponent&&e.renderComponent(t.emptyComponent,0,`${n}-empty`),!h&&t.selectable&&e.sceneData._selectMode&&u.length>0&&E("div",{key:`${n}-sel-hdr`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:((C=t.selectionStyle)==null?void 0:C.headerPadding)||"0.5rem 2rem"}},E("button",{type:"button",onClick:()=>{const x=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[],k=u.map((T,P)=>String(T.id||P)),S=k.length>0&&k.every(T=>x.includes(T));e.setSceneData(T=>({...T,_selIds:S?[]:k}))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textSecondary,fontSize:"12px",fontFamily:"inherit",padding:"4px 0"}},(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).filter(x=>u.some(k=>String(k.id)===x)).length===u.filter(x=>x.id).length&&u.length>0?"Deselect all":"Select all"),(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length>0?E("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},...(Array.isArray(t.selectActions)?t.selectActions:[]).map((x,k)=>E("button",{key:k,type:"button",onClick:()=>{var T;const S=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[];S.length!==0&&((T=e.runBulkSelectAction)==null||T.call(e,x,t.dataSource,n,S))},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,transition:"all 0.15s ease",padding:"0"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=e.cfg.colors.border,S.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent",S.currentTarget.style.color=e.cfg.colors.textSecondary}},e.renderIcon(x.icon,12))),E("span",{style:{fontSize:"12px",color:e.cfg.colors.textMuted}},`${(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length} selected`)):null),!h&&u.length>0&&(()=>{var j,J,nt,it;const x=(j=t.groupBy)==null?void 0:j.field,k=Q=>{const ut=Q==null?void 0:Q[x];if(ut&&typeof ut=="object"&&ut._seconds)return ut._seconds*1e3;const Ct=Date.parse(ut);return isNaN(Ct)?0:Ct},S=Q=>{if(!Q)return"Earlier";const ut=new Date(Q),Ct=new Date,ft=qt=>`${qt.getFullYear()}-${qt.getMonth()}-${qt.getDate()}`;if(ft(ut)===ft(Ct))return"Today";const Dt=new Date(Ct);return Dt.setDate(Ct.getDate()-1),ft(ut)===ft(Dt)?"Yesterday":ut.toLocaleDateString()},P=((J=t.sort)==null?void 0:J.field)||x?[...u].sort((Q,ut)=>{var ft;const Ct=k(ut)-k(Q);return((ft=t.sort)==null?void 0:ft.direction)==="asc"?-Ct:Ct}):u,I=String(e.sceneData.recordingSearchApplied||"").trim().toLowerCase(),[L,O]=String(e.sceneData.recordingDateFilterApplied||"").split("|"),H=L?Date.parse(`${L}T00:00:00`):0,U=O?Date.parse(`${O}T23:59:59.999`):Number.POSITIVE_INFINITY,X=((nt=t.itemsFilter)!=null&&nt.field?P.filter(Q=>String(Q==null?void 0:Q[t.itemsFilter.field])===String(t.itemsFilter.eq)):P).filter(Q=>{const ut=!I||[Q.url,Q.title,Q.prompt].some(ft=>String(ft||"").toLowerCase().includes(I)),Ct=k(Q);return ut&&Ct>=H&&Ct<=U}),V={};if(x)for(const Q of X)(V[it=S(k(Q))]||(V[it]=[])).push(Q);const D=(Q,ut)=>{var Ct,ft,Dt,qt,ne,te,mt,he;if(t.renderItem){const Pe=JSON.parse(JSON.stringify(t.renderItem)),ae={...Q};if(t.labelField&&t.labelMap){const bt=String(t.labelField.split(".").reduce((Rt,Lt)=>Rt==null?void 0:Rt[Lt],Q)??"");ae.label=t.labelMap[bt]??""}const Nn={};if(Array.isArray(Pe.children)){for(const bt of Pe.children)if(bt.content){const Rt=bt.content.match(/^\{\{(\w+)\}\}$/);if(Rt){const Lt=Rt[1],kt=Q[Lt];Array.isArray(kt)&&(Nn[Lt]=kt)}}}const Oe=JSON.stringify(Pe).replace(/\{\{([\w.]+)(?:\|(date|time|datetime|timeago))?\}\}/g,(bt,Rt,Lt)=>{const kt=Rt.split(".").reduce((yt,wt)=>yt==null?void 0:yt[wt],ae);if(Array.isArray(kt))return bt;if(kt==null)return"";if(Lt){const yt=kt&&typeof kt=="object"&&"_seconds"in kt?new Date(kt._seconds*1e3):new Date(kt);if(!isNaN(yt.getTime())){if(Lt==="timeago"){const wt=Math.floor((Date.now()-yt.getTime())/6e4);if(wt<1)return"just now";if(wt<60)return`${wt}m ago`;const gt=Math.floor(wt/60);if(gt<24)return`${gt}h ago`;const Xt=Math.floor(gt/24);return Xt<7?`${Xt}d ago`:yt.toLocaleDateString()}return Lt==="date"?yt.toLocaleDateString():Lt==="time"?yt.toLocaleTimeString():yt.toLocaleString()}}return typeof kt=="string"?kt.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):kt!==void 0?JSON.stringify(kt):""}),xe=JSON.parse(Oe);if(xe.children&&(xe.children=xe.children.map(bt=>{var kt;const Rt=bt.fieldType||"text",Lt=(kt=bt.content)==null?void 0:kt.match(/^\{\{(\w+)\}\}$/);if(Lt){const yt=Lt[1],wt=Nn[yt];if(wt)return Rt==="dropdown"?{...bt,type:"select",content:void 0,placeholder:bt.fieldPlaceholder||`Select ${yt}...`,options:wt.map(gt=>({label:typeof gt=="object"?gt.label||gt.name||JSON.stringify(gt):String(gt),value:typeof gt=="object"?gt.value||gt.id||JSON.stringify(gt):String(gt)})),name:`${n}-${ut}-${yt}`,className:bt.className||"w-full text-sm bg-slate-700 border border-slate-500 text-white rounded-lg px-3 py-1.5"}:Rt==="multiselect"?{...bt,type:"container",content:void 0,className:bt.className||"flex flex-col gap-1 w-full",children:[...bt.fieldPlaceholder?[{type:"text",content:bt.fieldPlaceholder,className:"text-xs text-gray-400 mb-1"}]:[{type:"text",content:`Select ${yt}`,className:"text-xs text-gray-400 mb-1"}],...wt.map((gt,Xt)=>({type:"checkbox",label:typeof gt=="object"?gt.label||gt.name||JSON.stringify(gt):String(gt),name:`${n}-${ut}-${yt}-${Xt}`,className:"text-sm text-gray-200"}))]}:Rt==="image-grid"?{...bt,type:"container",content:void 0,className:"flex flex-row gap-2 w-full overflow-x-auto py-1",children:wt.slice(0,10).map((gt,Xt)=>({type:"image",src:typeof gt=="string"?gt:gt.url||gt.src||"",alt:`${yt} ${Xt+1}`,className:"w-12 h-12 rounded-lg object-cover flex-shrink-0"}))}:{...bt,type:"container",content:void 0,className:"flex flex-col gap-1 w-full",children:[{type:"text",content:`⚠ "${yt}" is an array (${wt.length} items)`,className:"text-xs font-semibold text-amber-400"},{type:"text",content:"Use ⚡ to fetch fields, then set type in sidebar",className:"text-xs text-amber-300 opacity-75"}]}}return Rt==="image"&&bt.content&&!bt.content.includes("{{")?{...bt,type:"image",src:bt.content,alt:bt.content,content:void 0,className:bt.className||"w-full h-32 rounded-lg object-cover"}:bt})),t.selectable&&e.sceneData._selectMode){const bt=String(Q.id||ut),Rt=Array.isArray(e.sceneData._selIds)&&e.sceneData._selIds.map(String).includes(bt),Lt=yt=>yt?[yt.text,yt.content,...yt.children?yt.children.flatMap(Lt):[]].filter(wt=>typeof wt=="string"&&wt.trim()&&!wt.includes("{{")):[],kt=xe.text||xe.label||Lt(xe).slice(0,2).join(" — ")||String(Q.id||ut);return E("button",{key:`${n}-item-${ut}`,className:(Ct=t.selectionStyle)==null?void 0:Ct.className,type:"button",onClick:()=>{e.setSceneData(yt=>({...yt,_selIds:(()=>{const wt=Array.isArray(yt._selIds)?yt._selIds.map(String):[];return wt.includes(bt)?wt.filter(gt=>gt!==bt):[...wt,bt]})()}))},style:{width:"100%",textAlign:"left",padding:"1rem 2rem",border:`1px solid ${Rt?((ft=t.selectionStyle)==null?void 0:ft.selectedBorderColor)||e.cfg.colors.accent||"#fff":((Dt=t.selectionStyle)==null?void 0:Dt.borderColor)||e.cfg.colors.border}`,borderRadius:((qt=t.selectionStyle)==null?void 0:qt.borderRadius)||e.cfg.components.inputRadius||"8px",marginBottom:"0.5rem",backgroundColor:Rt?((ne=t.selectionStyle)==null?void 0:ne.selectedBackgroundColor)||e.cfg.colors.surface:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontFamily:"inherit",fontSize:"14px",fontWeight:Rt?600:400,transition:"all 0.15s ease",outline:"none"},onMouseEnter:yt=>{var gt,Xt;const wt=yt.currentTarget.firstElementChild;!Rt&&wt&&(wt.style.borderColor=((gt=t.selectionStyle)==null?void 0:gt.selectedBorderColor)||e.cfg.colors.accent||"#fff",wt.style.backgroundColor=((Xt=t.selectionStyle)==null?void 0:Xt.selectedBackgroundColor)||e.cfg.colors.surface,yt.currentTarget.style.borderColor=e.cfg.colors.textMuted)},onMouseLeave:yt=>{var gt,Xt,Ue;const wt=yt.currentTarget.firstElementChild;!Rt&&wt&&(wt.style.borderColor=((gt=t.selectionStyle)==null?void 0:gt.borderColor)||e.cfg.colors.border,wt.style.backgroundColor="transparent"),yt.currentTarget.style.borderColor=Rt?((Xt=t.selectionStyle)==null?void 0:Xt.selectedBorderColor)||e.cfg.colors.accent||"#fff":((Ue=t.selectionStyle)==null?void 0:Ue.borderColor)||e.cfg.colors.border}},E("span",{"aria-hidden":!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",marginRight:"10px",border:`1px solid ${Rt?((te=t.selectionStyle)==null?void 0:te.selectedBorderColor)||e.cfg.colors.accent||"#fff":((mt=t.selectionStyle)==null?void 0:mt.borderColor)||e.cfg.colors.border}`,borderRadius:"5px",backgroundColor:Rt?((he=t.selectionStyle)==null?void 0:he.selectedBorderColor)||e.cfg.colors.accent||"#fff":"transparent",color:Rt?e.cfg.colors.background:"transparent",transition:"all 0.15s ease"}},Rt?e.renderIcon("check",12):null),kt)}return E("div",{key:`${n}-row-${ut}`,style:{display:"contents"},onClickCapture:()=>{e.rowContextRef&&(e.rowContextRef.current=Q)}},e.renderComponent(xe,ut,`${n}-item`))}return null};return x?Object.entries(V).map(([Q,ut],Ct)=>E("div",{key:`${n}-group-${Ct}`,style:{display:"flex",flexDirection:"column",gap:"6px"}},E("div",{key:`${n}-group-hdr-${Ct}`,style:{fontSize:"11px",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",color:e.cfg.colors.textMuted,padding:"10px 4px 2px"}},Q),ut.map(D))):X.map(D)})(),r&&(s==null?void 0:s.hasMore)&&E("div",{"data-bf-scroll-load":n,style:{height:"48px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",...h&&((s==null?void 0:s.page)??0)>0?{}:{pointerEvents:"none",opacity:.55}}},h&&((s==null?void 0:s.page)??0)>0?E("div",{style:{width:"18px",height:"18px",border:"2px solid rgba(128,128,128,0.25)",borderTopColor:e.cfg.colors.primary,borderRadius:"50%",animation:"bf-spin 0.7s linear infinite"}}):E("div",{style:{width:"18px",height:"2px",borderRadius:"2px",background:e.cfg.colors.textMuted,opacity:.4}})),i&&m.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page-1,s.limit),disabled:s.page===0||h,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),E("span",{className:"text-xs text-gray-500"},`${s.page+1} / ${o}`),m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page+1,s.limit),disabled:!s.hasMore||h,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function uv({api:e,c:t,componentKey:n}){var H,U,q,X;const s=(H=e.paginationState)==null?void 0:H[n],i=t.pagination!==!1&&s&&s.total>s.limit,r=s?Math.ceil(s.total/s.limit):0,o=t.className||"w-full overflow-x-auto rounded-xl bg-gray-800/50 border border-gray-700/50",l=((U=e.parseClassNameResponsive)==null?void 0:U.call(e,o,n))??e.parseClassName(o);t.rawStyle&&Object.assign(l,t.rawStyle);const c=(q=e.loading)==null?void 0:q[n],h=(X=e.listData)==null?void 0:X[n],a=Array.isArray(h)?h:[],u=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{},f=!!t.sortable,p=t.sortMode==="client"?"client":"server",[g,d]=m.useState(null),[w,C]=m.useState({}),x=m.useMemo(()=>{if(!g||p!=="client")return a;const V=g.dir==="asc"?1:-1;return[...a].sort((D,j)=>{const J=D[g.key],nt=j[g.key];return J===nt?0:J==null?1:nt==null?-1:String(J).localeCompare(String(nt),void 0,{numeric:!0})*V})},[a,g,p]),k=V=>{if(!f&&!V.sortable)return;const D=V.field||V.key;let j=null;!g||g.key!==D?j={key:D,dir:"asc"}:g.dir==="asc"&&(j={key:D,dir:"desc"}),d(j),p==="server"&&j&&e.fetchListData(t.dataSource,n,0,(s==null?void 0:s.limit)||t.pageSize||10,j.key,j.dir)},S=(V,D)=>V.replace(/\{\{([\w.]+)(?:\s*\|\|\s*([^}]+))?\}\}/g,(j,J,nt)=>{const it=J.split(".").reduce((Q,ut)=>Q==null?void 0:Q[ut],D);return it==null||it===""?nt??"":String(it)}),T=async(V,D)=>{var nt;const j=w[V.id??""]||{},J=D.filter(it=>it.editable&&j[it.field||it.key]!==void 0);for(const it of J){const Q=it.field||it.key,ut=it.onCellChange||t.onSave;if(!ut)continue;const Ct=ut.replace(/\{\{field\}\}/g,JSON.stringify(j[Q]));if(Ct.startsWith("sdk:"))await e.handleButtonClick(S(Ct,V),{});else{const ft=S(Ct,V);await fetch(ft,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[Q]:j[Q]})})}}J.length&&((nt=e.showToast)==null||nt.call(e,(J.length===1,"Saved"),"success"),C(it=>{const Q={...it};return delete Q[V.id??""],Q}),e.fetchListData(t.dataSource,n,(s==null?void 0:s.page)||0,(s==null?void 0:s.limit)||t.pageSize||10))},P=(V,D,j)=>{const J=D.field||D.key,nt=V.id??"";C(it=>({...it,[nt]:{...it[nt]||{},[J]:j}}))},I=(V,D)=>{const j=V.field||V.key,J=D.id??"",nt=w[J]||{},it=nt[j]!==void 0?nt[j]:D[j],Q=V.fieldType||"text",ut={style:{width:"100%",background:"transparent",color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",padding:"2px 6px",fontSize:"13px",fontFamily:"inherit"}},Ct=()=>{V.onCellChange&&nt[V.key]!==void 0&&T(D,[V])};if(Q==="select"||Q==="dropdown")return E("select",{...ut,value:String(it??""),onChange:ft=>{P(D,V,ft.target.value),V.onCellChange&&T(D,[V])},children:(Array.isArray(V.fieldOptions)?V.fieldOptions:[]).map((ft,Dt)=>E("option",{key:Dt,value:ft.value,children:ft.label??ft.value}))});if(Q==="multiselect"){const ft=Array.isArray(it)?it:[];return E("div",{style:{display:"flex",flexDirection:"column",gap:2}},(Array.isArray(V.fieldOptions)?V.fieldOptions:[]).map((Dt,qt)=>{const ne=ft.includes(Dt.value);return E("label",{key:qt,style:{display:"flex",alignItems:"center",gap:4,fontSize:12}},E("input",{type:"checkbox",checked:ne,onChange:te=>{const mt=te.target.checked?[...ft,Dt.value]:ft.filter(he=>he!==Dt.value);P(D,V,mt),V.onCellChange&&T(D,[V])}}),E("span",{children:Dt.label??Dt.value}))}))}return Q==="image"?E("div",{style:{display:"flex",alignItems:"center",gap:6}},it?E("img",{src:String(it),alt:V.label,style:{width:32,height:32,borderRadius:4,objectFit:"cover"}}):null,E("input",{...ut,value:String(it??""),placeholder:V.fieldPlaceholder||"Image URL",onChange:ft=>P(D,V,ft.target.value),onBlur:Ct})):E("input",{...ut,type:Q==="number"?"number":"text",value:String(it??""),placeholder:V.fieldPlaceholder||"",onChange:ft=>P(D,V,Q==="number"?Number(ft.target.value):ft.target.value),onBlur:Ct})},L=V=>{const D=w[V.id??""];return!!D&&Object.keys(D).some(j=>{var J;return(J=t.columns)==null?void 0:J.some(nt=>nt.editable&&(nt.field||nt.key)===j)})},O=!!t.onSave;return m.createElement("div",{key:n,className:o,style:l,"data-component-key":n,...u},c&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):m.createElement("div",{className:"flex justify-center py-4"},E("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),m.createElement("table",{className:"w-full"},Array.isArray(t.columns)&&m.createElement("thead",{className:"bg-gray-900/50"},m.createElement("tr",{},t.columns.map(V=>m.createElement("th",{key:V.key,className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},(f||V.sortable)&&V.sortable!==!1?(()=>{const D=g&&g.key===V.key?g:null;return E("button",{type:"button",onClick:()=>k(V),style:{background:"none",border:"none",color:"inherit",fontFamily:"inherit",fontSize:"inherit",cursor:"pointer",padding:0},children:`${V.label||V.key}${D?D.dir==="asc"?" ↑":" ↓":" ⇅"}`})})():V.label||V.key)),O&&m.createElement("th",{key:"__save",className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},""))),m.createElement("tbody",{className:"divide-y divide-gray-700/50"},x.map((V,D)=>{var j;return m.createElement("tr",{key:V.id??D,className:"hover:bg-gray-700/30 transition-colors"},(j=t.columns)==null?void 0:j.map(J=>m.createElement("td",{key:J.key,className:"px-4 py-3 text-sm text-white"},J.editable?I(J,V):J.template?S(J.template,V):(()=>{const it=(J.field||J.key).split(".").reduce((Q,ut)=>Q==null?void 0:Q[ut],V);return it==null||it===""?"":String(it)})())),O&&m.createElement("td",{key:"__save-cell",className:"px-4 py-3 text-sm"},E("button",{type:"button",disabled:!L(V)||c,onClick:()=>T(V,t.columns||[]),className:"px-3 py-1 rounded text-xs font-semibold border transition-all disabled:opacity-40 disabled:cursor-not-allowed",style:{background:L(V)?e.cfg.colors.primary:"transparent",color:L(V)?"#ffffff":e.cfg.colors.textSecondary,borderColor:e.cfg.colors.border},children:"Save"})))}))),i&&m.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page-1,s.limit),disabled:s.page===0||c,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),E("span",{className:"text-xs text-gray-500"},`${s.page+1} / ${r}`),m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page+1,s.limit),disabled:!s.hasMore||c,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function dv(e,t,n){return m.createElement(uv,{api:e,c:t,componentKey:n})}function Nt(e){var t=e.width,n=e.height;if(t<0)throw new Error("Negative width is not allowed for Size");if(n<0)throw new Error("Negative height is not allowed for Size");return{width:t,height:n}}function Kn(e,t){return e.width===t.width&&e.height===t.height}var fv=function(){function e(t){var n=this;this._resolutionListener=function(){return n._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return e.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(e.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(t){var n=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){n._observers=n._observers.filter(function(i){return i!==s})}}},e.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},e.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},e.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},e.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(n){return n.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},e}();function mv(e){return new fv(e)}var pv=function(){function e(t,n,s){var i;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=Nt({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=n??function(r){return r},this._allowResizeObserver=(i=s==null?void 0:s.allowResizeObserver)!==null&&i!==void 0?i:!0,this._chooseAndInitObserver()}return e.prototype.dispose=function(){var t,n;if(this._canvasElement===null)throw new Error("Object is disposed");(t=this._canvasElementResizeObserver)===null||t===void 0||t.disconnect(),this._canvasElementResizeObserver=null,(n=this._devicePixelRatioObservable)===null||n===void 0||n.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(e.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bitmapSize",{get:function(){return Nt({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),e.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=Nt(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},e.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(n){return n!==t})},Object.defineProperty(e.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),e.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(n){return n!==t})},e.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},e.prototype._resizeBitmap=function(t){var n=this.bitmapSize;Kn(n,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(n,t))},e.prototype._emitBitmapSizeChanged=function(t,n){var s=this;this._bitmapSizeChangedListeners.forEach(function(i){return i.call(s,t,n)})},e.prototype._suggestNewBitmapSize=function(t){var n=this._suggestedBitmapSize,s=Nt(this._transformBitmapSize(t,this._canvasElementClientSize)),i=Kn(this.bitmapSize,s)?null:s;n===null&&i===null||n!==null&&i!==null&&Kn(n,i)||(this._suggestedBitmapSize=i,this._emitSuggestedBitmapSizeChanged(n,i))},e.prototype._emitSuggestedBitmapSizeChanged=function(t,n){var s=this;this._suggestedBitmapSizeChangedListeners.forEach(function(i){return i.call(s,t,n)})},e.prototype._chooseAndInitObserver=function(){var t=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}yv().then(function(n){return n?t._initResizeObserver():t._initDevicePixelRatioObservable()})},e.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var n=Ih(this._canvasElement);if(n===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=mv(n),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},e.prototype._invalidateBitmapSize=function(){var t,n;if(this._canvasElement!==null){var s=Ih(this._canvasElement);if(s!==null){var i=(n=(t=this._devicePixelRatioObservable)===null||t===void 0?void 0:t.value)!==null&&n!==void 0?n:s.devicePixelRatio,r=this._canvasElement.getClientRects(),o=r[0]!==void 0?bv(r[0],i):Nt({width:this._canvasElementClientSize.width*i,height:this._canvasElementClientSize.height*i});this._suggestNewBitmapSize(o)}}},e.prototype._initResizeObserver=function(){var t=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(n){var s=n.find(function(o){return o.target===t._canvasElement});if(!(!s||!s.devicePixelContentBoxSize||!s.devicePixelContentBoxSize[0])){var i=s.devicePixelContentBoxSize[0],r=Nt({width:i.inlineSize,height:i.blockSize});t._suggestNewBitmapSize(r)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},e}();function gv(e,t){return new pv(e,t.transform,t.options)}function Ih(e){return e.ownerDocument.defaultView}function yv(){return new Promise(function(e){var t=new ResizeObserver(function(n){e(n.every(function(s){return"devicePixelContentBoxSize"in s})),t.disconnect()});t.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function bv(e,t){return Nt({width:Math.round(e.left*t+e.width*t)-Math.round(e.left*t),height:Math.round(e.top*t+e.height*t)-Math.round(e.top*t)})}var vv=function(){function e(t,n,s){if(n.width===0||n.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=n,s.width===0||s.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return e.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},e.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(e.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),e}();function ts(e,t){var n=e.canvasElementClientSize;if(n.width===0||n.height===0)return null;var s=e.bitmapSize;if(s.width===0||s.height===0)return null;var i=e.canvasElement.getContext("2d",t);return i===null?null:new vv(i,n,s)}/*!
|
|
10
|
+
`),()=>{document.head.removeChild(a)}},[t]),cn.jsx(_p,{isPresent:t,childRef:s,sizeRef:i,children:Ra.cloneElement(e,{ref:s})})}const Np=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o})=>{const l=Da(Ip),c=m.useId(),h=m.useCallback(u=>{l.set(u,!0);for(const f of l.values())if(!f)return;s&&s()},[l,s]),a=m.useMemo(()=>({id:c,initial:t,isPresent:n,custom:i,onExitComplete:h,register:u=>(l.set(u,!1),()=>l.delete(u))}),r?[Math.random(),h]:[n,h]);return m.useMemo(()=>{l.forEach((u,f)=>l.set(f,!1))},[n]),Ra.useEffect(()=>{!n&&!l.size&&s&&s()},[n]),o==="popLayout"&&(e=cn.jsx($p,{isPresent:n,children:e})),cn.jsx(jr.Provider,{value:a,children:e})};function Ip(){return new Map}function Zu(e=!0){const t=m.useContext(jr);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,r=m.useId();m.useEffect(()=>{e&&i(r)},[e]);const o=m.useCallback(()=>e&&s&&s(r),[r,s,e]);return!n&&s?[!1,o]:[!0]}const Ji=e=>e.key||"";function gc(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const za=typeof window<"u",td=za?m.useLayoutEffect:m.useEffect,Dp=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1})=>{const[l,c]=Zu(o),h=m.useMemo(()=>gc(e),[e]),a=o&&!l?[]:h.map(Ji),u=m.useRef(!0),f=m.useRef(h),p=Da(()=>new Map),[g,d]=m.useState(h),[w,C]=m.useState(h);td(()=>{u.current=!1,f.current=h;for(let S=0;S<w.length;S++){const T=Ji(w[S]);a.includes(T)?p.delete(T):p.get(T)!==!0&&p.set(T,!1)}},[w,a.length,a.join("-")]);const x=[];if(h!==g){let S=[...h];for(let T=0;T<w.length;T++){const P=w[T],I=Ji(P);a.includes(I)||(S.splice(T,0,P),x.push(P))}r==="wait"&&x.length&&(S=x),C(gc(S)),d(h);return}process.env.NODE_ENV!=="production"&&r==="wait"&&w.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.`);const{forceRender:k}=m.useContext(Ia);return cn.jsx(cn.Fragment,{children:w.map(S=>{const T=Ji(S),P=o&&!l?!1:h===w||a.includes(T),I=()=>{if(p.has(T))p.set(T,!0);else return;let L=!0;p.forEach(O=>{O||(L=!1)}),L&&(k==null||k(),C(f.current),o&&(c==null||c()),s&&s())};return cn.jsx(Np,{isPresent:P,initial:!u.current||n?void 0:!1,custom:P?void 0:t,presenceAffectsLayout:i,mode:r,onExitComplete:P?void 0:I,children:S},T)})})},Ae=e=>e;let Us=Ae,An=Ae;process.env.NODE_ENV!=="production"&&(Us=(e,t)=>{!e&&typeof console<"u"&&console.warn(t)},An=(e,t)=>{if(!e)throw new Error(t)});function Fa(e){let t;return()=>(t===void 0&&(t=e()),t)}const Fs=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s},Qe=e=>e*1e3,hn=e=>e/1e3,Lp={useManualTiming:!1};function zp(e){let t=new Set,n=new Set,s=!1,i=!1;const r=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(h){r.has(h)&&(c.schedule(h),e()),h(o)}const c={schedule:(h,a=!1,u=!1)=>{const p=u&&s?t:n;return a&&r.add(h),p.has(h)||p.add(h),h},cancel:h=>{n.delete(h),r.delete(h)},process:h=>{if(o=h,s){i=!0;return}s=!0,[t,n]=[n,t],t.forEach(l),t.clear(),s=!1,i&&(i=!1,c.process(h))}};return c}const Ki=["read","resolveKeyframes","update","preRender","render","postRender"],Fp=40;function ed(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Ki.reduce((C,x)=>(C[x]=zp(r),C),{}),{read:l,resolveKeyframes:c,update:h,preRender:a,render:u,postRender:f}=o,p=()=>{const C=performance.now();n=!1,i.delta=s?1e3/60:Math.max(Math.min(C-i.timestamp,Fp),1),i.timestamp=C,i.isProcessing=!0,l.process(i),c.process(i),h.process(i),a.process(i),u.process(i),f.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(p))},g=()=>{n=!0,s=!0,i.isProcessing||e(p)};return{schedule:Ki.reduce((C,x)=>{const k=o[x];return C[x]=(S,T=!1,P=!1)=>(n||g(),k.schedule(S,T,P)),C},{}),cancel:C=>{for(let x=0;x<Ki.length;x++)o[Ki[x]].cancel(C)},state:i,steps:o}}const{schedule:Bt,cancel:Rn,state:me,steps:yo}=ed(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ae,!0),nd=m.createContext({strict:!1}),yc={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"]},Bs={};for(const e in yc)Bs[e]={isEnabled:t=>yc[e].some(n=>!!t[n])};function Bp(e){for(const t in e)Bs[t]={...Bs[t],...e[t]}}const Wp=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"]);function Er(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Wp.has(e)}let sd=e=>!Er(e);function jp(e){e&&(sd=t=>t.startsWith("on")?!Er(t):e(t))}try{jp(require("@emotion/is-prop-valid").default)}catch{}function Vp(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||(sd(i)||n===!0&&Er(i)||!t&&!Er(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const bc=new Set;function Vr(e,t,n){e||bc.has(t)||(console.warn(t),bc.add(t))}function Op(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...s)=>(process.env.NODE_ENV!=="production"&&Vr(!1,"motion() is deprecated. Use motion.create() instead."),e(...s));return new Proxy(n,{get:(s,i)=>i==="create"?e:(t.has(i)||t.set(i,e(i)),t.get(i))})}const Or=m.createContext({});function Ei(e){return typeof e=="string"||Array.isArray(e)}function Ur(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const Ba=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Wa=["initial",...Ba];function Hr(e){return Ur(e.animate)||Wa.some(t=>Ei(e[t]))}function id(e){return!!(Hr(e)||e.variants)}function Up(e,t){if(Hr(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Ei(n)?n:void 0,animate:Ei(s)?s:void 0}}return e.inherit!==!1?t:{}}function Hp(e){const{initial:t,animate:n}=Up(e,m.useContext(Or));return m.useMemo(()=>({initial:t,animate:n}),[vc(t),vc(n)])}function vc(e){return Array.isArray(e)?e.join(" "):e}const qp=Symbol.for("motionComponentSymbol");function As(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Gp(e,t,n){return m.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):As(n)&&(n.current=s))},[t])}const ja=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Yp="framerAppearId",rd="data-"+ja(Yp),{schedule:Va}=ed(queueMicrotask,!1),od=m.createContext({});function Xp(e,t,n,s,i){var r,o;const{visualElement:l}=m.useContext(Or),c=m.useContext(nd),h=m.useContext(jr),a=m.useContext(La).reducedMotion,u=m.useRef(null);s=s||c.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:l,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:a}));const f=u.current,p=m.useContext(od);f&&!f.projection&&i&&(f.type==="html"||f.type==="svg")&&Qp(u.current,n,i,p);const g=m.useRef(!1);m.useInsertionEffect(()=>{f&&g.current&&f.update(n,h)});const d=n[rd],w=m.useRef(!!d&&!(!((r=window.MotionHandoffIsComplete)===null||r===void 0)&&r.call(window,d))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,d)));return td(()=>{f&&(g.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),Va.render(f.render),w.current&&f.animationState&&f.animationState.animateChanges())}),m.useEffect(()=>{f&&(!w.current&&f.animationState&&f.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var C;(C=window.MotionHandoffMarkAsComplete)===null||C===void 0||C.call(window,d)}),w.current=!1))}),f}function Qp(e,t,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:ad(e.parent)),e.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||l&&As(l),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,layoutScroll:c,layoutRoot:h})}function ad(e){if(e)return e.options.allowProjection!==!1?e.projection:ad(e.parent)}function Jp({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:s,Component:i}){var r,o;e&&Bp(e);function l(h,a){let u;const f={...m.useContext(La),...h,layoutId:Kp(h)},{isStatic:p}=f,g=Hp(h),d=s(h,p);if(!p&&za){Zp(f,e);const w=tg(f);u=w.MeasureLayout,g.visualElement=Xp(i,d,f,t,w.ProjectionNode)}return cn.jsxs(Or.Provider,{value:g,children:[u&&g.visualElement?cn.jsx(u,{visualElement:g.visualElement,...f}):null,n(i,h,Gp(d,g.visualElement,a),d,p,g.visualElement)]})}l.displayName=`motion.${typeof i=="string"?i:`create(${(o=(r=i.displayName)!==null&&r!==void 0?r:i.name)!==null&&o!==void 0?o:""})`}`;const c=m.forwardRef(l);return c[qp]=i,c}function Kp({layoutId:e}){const t=m.useContext(Ia).id;return t&&e!==void 0?t+"-"+e:e}function Zp(e,t){const n=m.useContext(nd).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Us(!1,s):An(!1,s)}}function tg(e){const{drag:t,layout:n}=Bs;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}const eg=["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 Oa(e){return typeof e!="string"||e.includes("-")?!1:!!(eg.indexOf(e)>-1||/[A-Z]/u.test(e))}function xc(e){const t=[{},{}];return e==null||e.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Ua(e,t,n,s){if(typeof t=="function"){const[i,r]=xc(s);t=t(n!==void 0?n:e.custom,i,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,r]=xc(s);t=t(n!==void 0?n:e.custom,i,r)}return t}const ea=e=>Array.isArray(e),ng=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),sg=e=>ea(e)?e[e.length-1]||0:e,ve=e=>!!(e&&e.getVelocity);function yr(e){const t=ve(e)?e.get():e;return ng(t)?t.toValue():t}function ig({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},s,i,r){const o={latestValues:rg(s,i,r,e),renderState:t()};return n&&(o.onMount=l=>n({props:s,current:l,...o}),o.onUpdate=l=>n(l)),o}const ld=e=>(t,n)=>{const s=m.useContext(Or),i=m.useContext(jr),r=()=>ig(e,t,s,i);return n?r():Da(r)};function rg(e,t,n,s){const i={},r=s(e,{});for(const f in r)i[f]=yr(r[f]);let{initial:o,animate:l}=e;const c=Hr(e),h=id(e);t&&h&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let a=n?n.initial===!1:!1;a=a||o===!1;const u=a?l:o;if(u&&typeof u!="boolean"&&!Ur(u)){const f=Array.isArray(u)?u:[u];for(let p=0;p<f.length;p++){const g=Ua(e,f[p]);if(g){const{transitionEnd:d,transition:w,...C}=g;for(const x in C){let k=C[x];if(Array.isArray(k)){const S=a?k.length-1:0;k=k[S]}k!==null&&(i[x]=k)}for(const x in d)i[x]=d[x]}}}return i}const Hs=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],rs=new Set(Hs),cd=e=>t=>typeof t=="string"&&t.startsWith(e),hd=cd("--"),og=cd("var(--"),Ha=e=>og(e)?ag.test(e.split("/*")[0].trim()):!1,ag=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ud=(e,t)=>t&&typeof e=="number"?t.transform(e):e,un=(e,t,n)=>n>t?t:n<e?e:n,qs={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ti={...qs,transform:e=>un(0,1,e)},Zi={...qs,default:1},Ii=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Cn=Ii("deg"),Je=Ii("%"),ct=Ii("px"),lg=Ii("vh"),cg=Ii("vw"),wc={...Je,parse:e=>Je.parse(e)/100,transform:e=>Je.transform(e*100)},hg={borderWidth:ct,borderTopWidth:ct,borderRightWidth:ct,borderBottomWidth:ct,borderLeftWidth:ct,borderRadius:ct,radius:ct,borderTopLeftRadius:ct,borderTopRightRadius:ct,borderBottomRightRadius:ct,borderBottomLeftRadius:ct,width:ct,maxWidth:ct,height:ct,maxHeight:ct,top:ct,right:ct,bottom:ct,left:ct,padding:ct,paddingTop:ct,paddingRight:ct,paddingBottom:ct,paddingLeft:ct,margin:ct,marginTop:ct,marginRight:ct,marginBottom:ct,marginLeft:ct,backgroundPositionX:ct,backgroundPositionY:ct},ug={rotate:Cn,rotateX:Cn,rotateY:Cn,rotateZ:Cn,scale:Zi,scaleX:Zi,scaleY:Zi,scaleZ:Zi,skew:Cn,skewX:Cn,skewY:Cn,distance:ct,translateX:ct,translateY:ct,translateZ:ct,x:ct,y:ct,z:ct,perspective:ct,transformPerspective:ct,opacity:Ti,originX:wc,originY:wc,originZ:ct},Sc={...qs,transform:Math.round},qa={...hg,...ug,zIndex:Sc,size:ct,fillOpacity:Ti,strokeOpacity:Ti,numOctaves:Sc},dg={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fg=Hs.length;function mg(e,t,n){let s="",i=!0;for(let r=0;r<fg;r++){const o=Hs[r],l=e[o];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(o.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const h=ud(l,qa[o]);if(!c){i=!1;const a=dg[o]||o;s+=`${a}(${h}) `}n&&(t[o]=h)}}return s=s.trim(),n?s=n(t,i?"":s):i&&(s="none"),s}function Ga(e,t,n){const{style:s,vars:i,transformOrigin:r}=e;let o=!1,l=!1;for(const c in t){const h=t[c];if(rs.has(c)){o=!0;continue}else if(hd(c)){i[c]=h;continue}else{const a=ud(h,qa[c]);c.startsWith("origin")?(l=!0,r[c]=a):s[c]=a}}if(t.transform||(o||n?s.transform=mg(t,e.transform,n):s.transform&&(s.transform="none")),l){const{originX:c="50%",originY:h="50%",originZ:a=0}=r;s.transformOrigin=`${c} ${h} ${a}`}}const pg={offset:"stroke-dashoffset",array:"stroke-dasharray"},gg={offset:"strokeDashoffset",array:"strokeDasharray"};function yg(e,t,n=1,s=0,i=!0){e.pathLength=1;const r=i?pg:gg;e[r.offset]=ct.transform(-s);const o=ct.transform(t),l=ct.transform(n);e[r.array]=`${o} ${l}`}function Cc(e,t,n){return typeof e=="string"?e:ct.transform(t+n*e)}function bg(e,t,n){const s=Cc(t,e.x,e.width),i=Cc(n,e.y,e.height);return`${s} ${i}`}function Ya(e,{attrX:t,attrY:n,attrScale:s,originX:i,originY:r,pathLength:o,pathSpacing:l=1,pathOffset:c=0,...h},a,u){if(Ga(e,h,u),a){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:p,dimensions:g}=e;f.transform&&(g&&(p.transform=f.transform),delete f.transform),g&&(i!==void 0||r!==void 0||p.transform)&&(p.transformOrigin=bg(g,i!==void 0?i:.5,r!==void 0?r:.5)),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),s!==void 0&&(f.scale=s),o!==void 0&&yg(f,o,l,c,!1)}const Xa=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),dd=()=>({...Xa(),attrs:{}}),Qa=e=>typeof e=="string"&&e.toLowerCase()==="svg";function fd(e,{style:t,vars:n},s,i){Object.assign(e.style,t,i&&i.getProjectionStyles(s));for(const r in n)e.style.setProperty(r,n[r])}const md=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 pd(e,t,n,s){fd(e,t,void 0,s);for(const i in t.attrs)e.setAttribute(md.has(i)?i:ja(i),t.attrs[i])}const Tr={};function vg(e){Object.assign(Tr,e)}function gd(e,{layout:t,layoutId:n}){return rs.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Tr[e]||e==="opacity")}function Ja(e,t,n){var s;const{style:i}=e,r={};for(const o in i)(ve(i[o])||t.style&&ve(t.style[o])||gd(o,e)||((s=n==null?void 0:n.getValue(o))===null||s===void 0?void 0:s.liveStyle)!==void 0)&&(r[o]=i[o]);return r}function yd(e,t,n){const s=Ja(e,t,n);for(const i in e)if(ve(e[i])||ve(t[i])){const r=Hs.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=e[i]}return s}function xg(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const kc=["x","y","width","height","cx","cy","r"],wg={useVisualState:ld({scrapeMotionValuesFromProps:yd,createRenderState:dd,onUpdate:({props:e,prevProps:t,current:n,renderState:s,latestValues:i})=>{if(!n)return;let r=!!e.drag;if(!r){for(const l in i)if(rs.has(l)){r=!0;break}}if(!r)return;let o=!t;if(t)for(let l=0;l<kc.length;l++){const c=kc[l];e[c]!==t[c]&&(o=!0)}o&&Bt.read(()=>{xg(n,s),Bt.render(()=>{Ya(s,i,Qa(n.tagName),e.transformTemplate),pd(n,s)})})}})},Sg={useVisualState:ld({scrapeMotionValuesFromProps:Ja,createRenderState:Xa})};function bd(e,t,n){for(const s in t)!ve(t[s])&&!gd(s,n)&&(e[s]=t[s])}function Cg({transformTemplate:e},t){return m.useMemo(()=>{const n=Xa();return Ga(n,t,e),Object.assign({},n.vars,n.style)},[t])}function kg(e,t){const n=e.style||{},s={};return bd(s,n,e),Object.assign(s,Cg(e,t)),s}function Mg(e,t){const n={},s=kg(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.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=s,n}function Eg(e,t,n,s){const i=m.useMemo(()=>{const r=dd();return Ya(r,t,Qa(s),e.transformTemplate),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};bd(r,e.style,e),i.style={...r,...i.style}}return i}function Tg(e=!1){return(n,s,i,{latestValues:r},o)=>{const c=(Oa(n)?Eg:Mg)(s,r,o,n),h=Vp(s,typeof n=="string",e),a=n!==m.Fragment?{...h,...c,ref:i}:{},{children:u}=s,f=m.useMemo(()=>ve(u)?u.get():u,[u]);return m.createElement(n,{...a,children:f})}}function Ag(e,t){return function(s,{forwardMotionProps:i}={forwardMotionProps:!1}){const o={...Oa(s)?wg:Sg,preloadedFeatures:e,useRender:Tg(i),createVisualElement:t,Component:s};return Jp(o)}}function vd(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}function qr(e,t,n){const s=e.getProps();return Ua(s,t,n!==void 0?n:s.custom,e)}const Rg=Fa(()=>window.ScrollTimeline!==void 0);class Pg{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let s=0;s<this.animations.length;s++)this.animations[s][t]=n}attachTimeline(t,n){const s=this.animations.map(i=>{if(Rg()&&i.attachTimeline)return i.attachTimeline(t);if(typeof n=="function")return n(i)});return()=>{s.forEach((i,r)=>{i&&i(),this.animations[r].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class _g extends Pg{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}function Ka(e,t){return e?e[t]||e.default||e:void 0}const na=2e4;function xd(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<na;)t+=n,s=e.next(t);return t>=na?1/0:t}function Za(e){return typeof e=="function"}function Mc(e,t){e.timeline=t,e.onfinish=null}const tl=e=>Array.isArray(e)&&typeof e[0]=="number",$g={linearEasing:void 0};function Ng(e,t){const n=Fa(e);return()=>{var s;return(s=$g[t])!==null&&s!==void 0?s:n()}}const Ar=Ng(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),wd=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let r=0;r<i;r++)s+=e(Fs(0,i-1,r))+", ";return`linear(${s.substring(0,s.length-2)})`};function Sd(e){return!!(typeof e=="function"&&Ar()||!e||typeof e=="string"&&(e in sa||Ar())||tl(e)||Array.isArray(e)&&e.every(Sd))}const hi=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,sa={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:hi([0,.65,.55,1]),circOut:hi([.55,0,1,.45]),backIn:hi([.31,.01,.66,-.59]),backOut:hi([.33,1.53,.69,.99])};function Cd(e,t){if(e)return typeof e=="function"&&Ar()?wd(e,t):tl(e)?hi(e):Array.isArray(e)?e.map(n=>Cd(n,t)||sa.easeOut):sa[e]}const Ve={x:!1,y:!1};function kd(){return Ve.x||Ve.y}function Ig(e,t,n){var s;if(e instanceof Element)return[e];if(typeof e=="string"){let i=document;const r=(s=void 0)!==null&&s!==void 0?s:i.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e)}function Md(e,t){const n=Ig(e),s=new AbortController,i={passive:!0,...t,signal:s.signal};return[n,i,()=>s.abort()]}function Ec(e){return t=>{t.pointerType==="touch"||kd()||e(t)}}function Dg(e,t,n={}){const[s,i,r]=Md(e,n),o=Ec(l=>{const{target:c}=l,h=t(l);if(typeof h!="function"||!c)return;const a=Ec(u=>{h(u),c.removeEventListener("pointerleave",a)});c.addEventListener("pointerleave",a,i)});return s.forEach(l=>{l.addEventListener("pointerenter",o,i)}),r}const Ed=(e,t)=>t?e===t?!0:Ed(e,t.parentElement):!1,el=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Lg=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function zg(e){return Lg.has(e.tagName)||e.tabIndex!==-1}const ui=new WeakSet;function Tc(e){return t=>{t.key==="Enter"&&e(t)}}function bo(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Fg=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Tc(()=>{if(ui.has(n))return;bo(n,"down");const i=Tc(()=>{bo(n,"up")}),r=()=>bo(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function Ac(e){return el(e)&&!kd()}function Bg(e,t,n={}){const[s,i,r]=Md(e,n),o=l=>{const c=l.currentTarget;if(!Ac(l)||ui.has(c))return;ui.add(c);const h=t(l),a=(p,g)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",f),!(!Ac(p)||!ui.has(c))&&(ui.delete(c),typeof h=="function"&&h(p,{success:g}))},u=p=>{a(p,n.useGlobalTarget||Ed(c,p.target))},f=p=>{a(p,!1)};window.addEventListener("pointerup",u,i),window.addEventListener("pointercancel",f,i)};return s.forEach(l=>{!zg(l)&&l.getAttribute("tabindex")===null&&(l.tabIndex=0),(n.useGlobalTarget?window:l).addEventListener("pointerdown",o,i),l.addEventListener("focus",h=>Fg(h,i),i)}),r}function Wg(e){return e==="x"||e==="y"?Ve[e]?null:(Ve[e]=!0,()=>{Ve[e]=!1}):Ve.x||Ve.y?null:(Ve.x=Ve.y=!0,()=>{Ve.x=Ve.y=!1})}const Td=new Set(["width","height","top","left","right","bottom",...Hs]);let br;function jg(){br=void 0}const Ke={now:()=>(br===void 0&&Ke.set(me.isProcessing||Lp.useManualTiming?me.timestamp:performance.now()),br),set:e=>{br=e,queueMicrotask(jg)}};function nl(e,t){e.indexOf(t)===-1&&e.push(t)}function sl(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class il{constructor(){this.subscriptions=[]}add(t){return nl(this.subscriptions,t),()=>sl(this.subscriptions,t)}notify(t,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function Ad(e,t){return t?e*(1e3/t):0}const Rc=30,Vg=e=>!isNaN(parseFloat(e));class Og{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(s,i=!0)=>{const r=Ke.now();this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ke.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Vg(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Vr(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new il);const s=this.events[t].add(n);return t==="change"?()=>{s(),Bt.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Ke.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Rc)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Rc);return Ad(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ai(e,t){return new Og(e,t)}function Ug(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ai(n))}function Hg(e,t){const n=qr(e,t);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const l=sg(r[o]);Ug(e,o,l)}}function qg(e){return!!(ve(e)&&e.add)}function ia(e,t){const n=e.getValue("willChange");if(qg(n))return n.add(t)}function Rd(e){return e.props[rd]}const Pd=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Gg=1e-7,Yg=12;function Xg(e,t,n,s,i){let r,o,l=0;do o=t+(n-t)/2,r=Pd(o,s,i)-e,r>0?n=o:t=o;while(Math.abs(r)>Gg&&++l<Yg);return o}function Di(e,t,n,s){if(e===t&&n===s)return Ae;const i=r=>Xg(r,0,1,e,n);return r=>r===0||r===1?r:Pd(i(r),t,s)}const _d=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,$d=e=>t=>1-e(1-t),Nd=Di(.33,1.53,.69,.99),rl=$d(Nd),Id=_d(rl),Dd=e=>(e*=2)<1?.5*rl(e):.5*(2-Math.pow(2,-10*(e-1))),ol=e=>1-Math.sin(Math.acos(e)),Ld=$d(ol),zd=_d(ol),Fd=e=>/^0[^.\s]+$/u.test(e);function Qg(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Fd(e):!0}const gi=e=>Math.round(e*1e5)/1e5,al=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Jg(e){return e==null}const Kg=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ll=(e,t)=>n=>!!(typeof n=="string"&&Kg.test(n)&&n.startsWith(e)||t&&!Jg(n)&&Object.prototype.hasOwnProperty.call(n,t)),Bd=(e,t,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,l]=s.match(al);return{[e]:parseFloat(i),[t]:parseFloat(r),[n]:parseFloat(o),alpha:l!==void 0?parseFloat(l):1}},Zg=e=>un(0,255,e),vo={...qs,transform:e=>Math.round(Zg(e))},Jn={test:ll("rgb","red"),parse:Bd("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+vo.transform(e)+", "+vo.transform(t)+", "+vo.transform(n)+", "+gi(Ti.transform(s))+")"};function t0(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const ra={test:ll("#"),parse:t0,transform:Jn.transform},Rs={test:ll("hsl","hue"),parse:Bd("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+Je.transform(gi(t))+", "+Je.transform(gi(n))+", "+gi(Ti.transform(s))+")"},be={test:e=>Jn.test(e)||ra.test(e)||Rs.test(e),parse:e=>Jn.test(e)?Jn.parse(e):Rs.test(e)?Rs.parse(e):ra.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Jn.transform(e):Rs.transform(e)},e0=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function n0(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(al))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(e0))===null||n===void 0?void 0:n.length)||0)>0}const Wd="number",jd="color",s0="var",i0="var(",Pc="${}",r0=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ri(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const l=t.replace(r0,c=>(be.test(c)?(s.color.push(r),i.push(jd),n.push(be.parse(c))):c.startsWith(i0)?(s.var.push(r),i.push(s0),n.push(c)):(s.number.push(r),i.push(Wd),n.push(parseFloat(c))),++r,Pc)).split(Pc);return{values:n,split:l,indexes:s,types:i}}function Vd(e){return Ri(e).values}function Od(e){const{split:t,types:n}=Ri(e),s=t.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=t[o],i[o]!==void 0){const l=n[o];l===Wd?r+=gi(i[o]):l===jd?r+=be.transform(i[o]):r+=i[o]}return r}}const o0=e=>typeof e=="number"?0:e;function a0(e){const t=Vd(e);return Od(e)(t.map(o0))}const Pn={test:n0,parse:Vd,createTransformer:Od,getAnimatableNone:a0},l0=new Set(["brightness","contrast","saturate","opacity"]);function c0(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(al)||[];if(!s)return e;const i=n.replace(s,"");let r=l0.has(t)?1:0;return s!==n&&(r*=100),t+"("+r+i+")"}const h0=/\b([a-z-]*)\(.*?\)/gu,oa={...Pn,getAnimatableNone:e=>{const t=e.match(h0);return t?t.map(c0).join(" "):e}},u0={...qa,color:be,backgroundColor:be,outlineColor:be,fill:be,stroke:be,borderColor:be,borderTopColor:be,borderRightColor:be,borderBottomColor:be,borderLeftColor:be,filter:oa,WebkitFilter:oa},cl=e=>u0[e];function Ud(e,t){let n=cl(e);return n!==oa&&(n=Pn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const d0=new Set(["auto","none","0"]);function f0(e,t,n){let s=0,i;for(;s<e.length&&!i;){const r=e[s];typeof r=="string"&&!d0.has(r)&&Ri(r).values.length&&(i=e[s]),s++}if(i&&n)for(const r of t)e[r]=Ud(n,i)}const _c=e=>e===qs||e===ct,$c=(e,t)=>parseFloat(e.split(", ")[t]),Nc=(e,t)=>(n,{transform:s})=>{if(s==="none"||!s)return 0;const i=s.match(/^matrix3d\((.+)\)$/u);if(i)return $c(i[1],t);{const r=s.match(/^matrix\((.+)\)$/u);return r?$c(r[1],e):0}},m0=new Set(["x","y","z"]),p0=Hs.filter(e=>!m0.has(e));function g0(e){const t=[];return p0.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Ws={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:Nc(4,13),y:Nc(5,14)};Ws.translateX=Ws.x;Ws.translateY=Ws.y;const Kn=new Set;let aa=!1,la=!1;function Hd(){if(la){const e=Array.from(Kn).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const i=g0(s);i.length&&(n.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{var l;(l=s.getValue(r))===null||l===void 0||l.set(o)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}la=!1,aa=!1,Kn.forEach(e=>e.complete()),Kn.clear()}function qd(){Kn.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(la=!0)})}function y0(){qd(),Hd()}class hl{constructor(t,n,s,i,r,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Kn.add(this),aa||(aa=!0,Bt.read(qd),Bt.resolveKeyframes(Hd))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:i}=this;for(let r=0;r<t.length;r++)if(t[r]===null)if(r===0){const o=i==null?void 0:i.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const c=s.readValue(n,l);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=l),i&&o===void 0&&i.set(t[0])}else t[r]=t[r-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Kn.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Kn.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const Gd=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),b0=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function v0(e){const t=b0.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${n??s}`,i]}const x0=4;function Yd(e,t,n=1){An(n<=x0,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);const[s,i]=v0(e);if(!s)return;const r=window.getComputedStyle(t).getPropertyValue(s);if(r){const o=r.trim();return Gd(o)?parseFloat(o):o}return Ha(i)?Yd(i,t,n+1):i}const Xd=e=>t=>t.test(e),w0={test:e=>e==="auto",parse:e=>e},Qd=[qs,ct,Je,Cn,cg,lg,w0],Ic=e=>Qd.find(Xd(e));class Jd extends hl{constructor(t,n,s,i,r){super(t,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let h=t[c];if(typeof h=="string"&&(h=h.trim(),Ha(h))){const a=Yd(h,n.current);a!==void 0&&(t[c]=a),c===t.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!Td.has(s)||t.length!==2)return;const[i,r]=t,o=Ic(i),l=Ic(r);if(o!==l)if(_c(o)&&_c(l))for(let c=0;c<t.length;c++){const h=t[c];typeof h=="string"&&(t[c]=parseFloat(h))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let i=0;i<t.length;i++)Qg(t[i])&&s.push(i);s.length&&f0(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ws[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(s,i).jump(i,!1)}measureEndState(){var t;const{element:n,name:s,unresolvedKeyframes:i}=this;if(!n||!n.current)return;const r=n.getValue(s);r&&r.jump(this.measuredOrigin,!1);const o=i.length-1,l=i[o];i[o]=Ws[s](n.measureViewportBox(),window.getComputedStyle(n.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([c,h])=>{n.getValue(c).set(h)}),this.resolveNoneKeyframes()}}const Dc=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Pn.test(e)||e==="0")&&!e.startsWith("url("));function S0(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function C0(e,t,n,s){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],o=Dc(i,t),l=Dc(r,t);return Us(o===l,`You are trying to animate ${t} from "${i}" to "${r}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${r} via the \`style\` property.`),!o||!l?!1:S0(e)||(n==="spring"||Za(n))&&s}const k0=e=>e!==null;function Gr(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(k0),r=t&&n!=="loop"&&t%2===1?0:i.length-1;return!r||s===void 0?i[r]:s}const M0=40;class Kd{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",...l}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=Ke.now(),this.options={autoplay:t,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,...l},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>M0?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&y0(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=Ke.now(),this.hasAttemptedResolve=!0;const{name:s,type:i,velocity:r,delay:o,onComplete:l,onUpdate:c,isGenerator:h}=this.options;if(!h&&!C0(t,s,i,r))if(o)this.options.duration=0;else{c&&c(Gr(t,this.options,n)),l&&l(),this.resolveFinishedPromise();return}const a=this.initPlayback(t,n);a!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...a},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const Ht=(e,t,n)=>e+(t-e)*n;function xo(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function E0({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let i=0,r=0,o=0;if(!t)i=r=o=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;i=xo(c,l,e+1/3),r=xo(c,l,e),o=xo(c,l,e-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Rr(e,t){return n=>n>0?t:e}const wo=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},T0=[ra,Jn,Rs],A0=e=>T0.find(t=>t.test(e));function Lc(e){const t=A0(e);if(Us(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(e);return t===Rs&&(n=E0(n)),n}const zc=(e,t)=>{const n=Lc(e),s=Lc(t);if(!n||!s)return Rr(e,t);const i={...n};return r=>(i.red=wo(n.red,s.red,r),i.green=wo(n.green,s.green,r),i.blue=wo(n.blue,s.blue,r),i.alpha=Ht(n.alpha,s.alpha,r),Jn.transform(i))},R0=(e,t)=>n=>t(e(n)),Li=(...e)=>e.reduce(R0),ca=new Set(["none","hidden"]);function P0(e,t){return ca.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function _0(e,t){return n=>Ht(e,t,n)}function ul(e){return typeof e=="number"?_0:typeof e=="string"?Ha(e)?Rr:be.test(e)?zc:I0:Array.isArray(e)?Zd:typeof e=="object"?be.test(e)?zc:$0:Rr}function Zd(e,t){const n=[...e],s=n.length,i=e.map((r,o)=>ul(r)(r,t[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function $0(e,t){const n={...e,...t},s={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(s[i]=ul(e[i])(e[i],t[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function N0(e,t){var n;const s=[],i={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],l=e.indexes[o][i[o]],c=(n=e.values[l])!==null&&n!==void 0?n:0;s[r]=c,i[o]++}return s}const I0=(e,t)=>{const n=Pn.createTransformer(t),s=Ri(e),i=Ri(t);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?ca.has(e)&&!i.values.length||ca.has(t)&&!s.values.length?P0(e,t):Li(Zd(N0(s,i),i.values),n):(Us(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),Rr(e,t))};function tf(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Ht(e,t,n):ul(e)(e,t)}const D0=5;function ef(e,t,n){const s=Math.max(t-D0,0);return Ad(n-e(s),t-s)}const Ut={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},So=.001;function L0({duration:e=Ut.duration,bounce:t=Ut.bounce,velocity:n=Ut.velocity,mass:s=Ut.mass}){let i,r;Us(e<=Qe(Ut.maxDuration),"Spring duration must be 10 seconds or less");let o=1-t;o=un(Ut.minDamping,Ut.maxDamping,o),e=un(Ut.minDuration,Ut.maxDuration,hn(e)),o<1?(i=h=>{const a=h*o,u=a*e,f=a-n,p=ha(h,o),g=Math.exp(-u);return So-f/p*g},r=h=>{const u=h*o*e,f=u*n+n,p=Math.pow(o,2)*Math.pow(h,2)*e,g=Math.exp(-u),d=ha(Math.pow(h,2),o);return(-i(h)+So>0?-1:1)*((f-p)*g)/d}):(i=h=>{const a=Math.exp(-h*e),u=(h-n)*e+1;return-So+a*u},r=h=>{const a=Math.exp(-h*e),u=(n-h)*(e*e);return a*u});const l=5/e,c=F0(i,r,l);if(e=Qe(e),isNaN(c))return{stiffness:Ut.stiffness,damping:Ut.damping,duration:e};{const h=Math.pow(c,2)*s;return{stiffness:h,damping:o*2*Math.sqrt(s*h),duration:e}}}const z0=12;function F0(e,t,n){let s=n;for(let i=1;i<z0;i++)s=s-e(s)/t(s);return s}function ha(e,t){return e*Math.sqrt(1-t*t)}const B0=["duration","bounce"],W0=["stiffness","damping","mass"];function Fc(e,t){return t.some(n=>e[n]!==void 0)}function j0(e){let t={velocity:Ut.velocity,stiffness:Ut.stiffness,damping:Ut.damping,mass:Ut.mass,isResolvedFromDuration:!1,...e};if(!Fc(e,W0)&&Fc(e,B0))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*un(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ut.mass,stiffness:i,damping:r}}else{const n=L0(e);t={...t,...n,mass:Ut.mass},t.isResolvedFromDuration=!0}return t}function nf(e=Ut.visualDuration,t=Ut.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:r},{stiffness:c,damping:h,mass:a,duration:u,velocity:f,isResolvedFromDuration:p}=j0({...n,velocity:-hn(n.velocity||0)}),g=f||0,d=h/(2*Math.sqrt(c*a)),w=o-r,C=hn(Math.sqrt(c/a)),x=Math.abs(w)<5;s||(s=x?Ut.restSpeed.granular:Ut.restSpeed.default),i||(i=x?Ut.restDelta.granular:Ut.restDelta.default);let k;if(d<1){const T=ha(C,d);k=P=>{const I=Math.exp(-d*C*P);return o-I*((g+d*C*w)/T*Math.sin(T*P)+w*Math.cos(T*P))}}else if(d===1)k=T=>o-Math.exp(-C*T)*(w+(g+C*w)*T);else{const T=C*Math.sqrt(d*d-1);k=P=>{const I=Math.exp(-d*C*P),L=Math.min(T*P,300);return o-I*((g+d*C*w)*Math.sinh(L)+T*w*Math.cosh(L))/T}}const S={calculatedDuration:p&&u||null,next:T=>{const P=k(T);if(p)l.done=T>=u;else{let I=0;d<1&&(I=T===0?Qe(g):ef(k,T,P));const L=Math.abs(I)<=s,O=Math.abs(o-P)<=i;l.done=L&&O}return l.value=l.done?o:P,l},toString:()=>{const T=Math.min(xd(S),na),P=wd(I=>S.next(T*I).value,T,30);return T+"ms "+P}};return S}function Bc({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:l,max:c,restDelta:h=.5,restSpeed:a}){const u=e[0],f={done:!1,value:u},p=L=>l!==void 0&&L<l||c!==void 0&&L>c,g=L=>l===void 0?c:c===void 0||Math.abs(l-L)<Math.abs(c-L)?l:c;let d=n*t;const w=u+d,C=o===void 0?w:o(w);C!==w&&(d=C-u);const x=L=>-d*Math.exp(-L/s),k=L=>C+x(L),S=L=>{const O=x(L),H=k(L);f.done=Math.abs(O)<=h,f.value=f.done?C:H};let T,P;const I=L=>{p(f.value)&&(T=L,P=nf({keyframes:[f.value,g(f.value)],velocity:ef(k,L,f.value),damping:i,stiffness:r,restDelta:h,restSpeed:a}))};return I(0),{calculatedDuration:null,next:L=>{let O=!1;return!P&&T===void 0&&(O=!0,S(L),I(L)),T!==void 0&&L>=T?P.next(L-T):(!O&&S(L),f)}}}const V0=Di(.42,0,1,1),O0=Di(0,0,.58,1),sf=Di(.42,0,.58,1),U0=e=>Array.isArray(e)&&typeof e[0]!="number",Wc={linear:Ae,easeIn:V0,easeInOut:sf,easeOut:O0,circIn:ol,circInOut:zd,circOut:Ld,backIn:rl,backInOut:Id,backOut:Nd,anticipate:Dd},jc=e=>{if(tl(e)){An(e.length===4,"Cubic bezier arrays must contain four numerical values.");const[t,n,s,i]=e;return Di(t,n,s,i)}else if(typeof e=="string")return An(Wc[e]!==void 0,`Invalid easing type '${e}'`),Wc[e];return e};function H0(e,t,n){const s=[],i=n||tf,r=e.length-1;for(let o=0;o<r;o++){let l=i(e[o],e[o+1]);if(t){const c=Array.isArray(t)?t[o]||Ae:t;l=Li(c,l)}s.push(l)}return s}function q0(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const r=e.length;if(An(r===t.length,"Both input and output ranges must be the same length"),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=H0(t,s,i),c=l.length,h=a=>{if(o&&a<e[0])return t[0];let u=0;if(c>1)for(;u<e.length-2&&!(a<e[u+1]);u++);const f=Fs(e[u],e[u+1],a);return l[u](f)};return n?a=>h(un(e[0],e[r-1],a)):h}function G0(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=Fs(0,t,s);e.push(Ht(n,1,i))}}function Y0(e){const t=[0];return G0(t,e.length-1),t}function X0(e,t){return e.map(n=>n*t)}function Q0(e,t){return e.map(()=>t||sf).splice(0,e.length-1)}function Pr({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=U0(s)?s.map(jc):jc(s),r={done:!1,value:t[0]},o=X0(n&&n.length===t.length?n:Y0(t),e),l=q0(o,t,{ease:Array.isArray(i)?i:Q0(t,i)});return{calculatedDuration:e,next:c=>(r.value=l(c),r.done=c>=e,r)}}const J0=e=>{const t=({timestamp:n})=>e(n);return{start:()=>Bt.update(t,!0),stop:()=>Rn(t),now:()=>me.isProcessing?me.timestamp:Ke.now()}},K0={decay:Bc,inertia:Bc,tween:Pr,keyframes:Pr,spring:nf},Z0=e=>e/100;class dl extends Kd{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:c}=this.options;c&&c()};const{name:n,motionValue:s,element:i,keyframes:r}=this.options,o=(i==null?void 0:i.KeyframeResolver)||hl,l=(c,h)=>this.onKeyframesResolved(c,h);this.resolver=new o(r,l,n,s,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=this.options,l=Za(n)?n:K0[n]||Pr;let c,h;l!==Pr&&typeof t[0]!="number"&&(process.env.NODE_ENV!=="production"&&An(t.length===2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${t}`),c=Li(Z0,tf(t[0],t[1])),t=[0,100]);const a=l({...this.options,keyframes:t});r==="mirror"&&(h=l({...this.options,keyframes:[...t].reverse(),velocity:-o})),a.calculatedDuration===null&&(a.calculatedDuration=xd(a));const{calculatedDuration:u}=a,f=u+i,p=f*(s+1)-i;return{generator:a,mirroredGenerator:h,mapPercentToKeyframes:c,calculatedDuration:u,resolvedDuration:f,totalDuration:p}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:s}=this;if(!s){const{keyframes:L}=this.options;return{done:!0,value:L[L.length-1]}}const{finalKeyframe:i,generator:r,mirroredGenerator:o,mapPercentToKeyframes:l,keyframes:c,calculatedDuration:h,totalDuration:a,resolvedDuration:u}=s;if(this.startTime===null)return r.next(0);const{delay:f,repeat:p,repeatType:g,repeatDelay:d,onUpdate:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const C=this.currentTime-f*(this.speed>=0?1:-1),x=this.speed>=0?C<0:C>a;this.currentTime=Math.max(C,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let k=this.currentTime,S=r;if(p){const L=Math.min(this.currentTime,a)/u;let O=Math.floor(L),H=L%1;!H&&L>=1&&(H=1),H===1&&O--,O=Math.min(O,p+1),!!(O%2)&&(g==="reverse"?(H=1-H,d&&(H-=d/u)):g==="mirror"&&(S=o)),k=un(0,1,H)*u}const T=x?{done:!1,value:c[0]}:S.next(k);l&&(T.value=l(T.value));let{done:P}=T;!x&&h!==null&&(P=this.speed>=0?this.currentTime>=a:this.currentTime<=0);const I=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&P);return I&&i!==void 0&&(T.value=Gr(c,this.options,i)),w&&w(T.value),I&&this.finish(),T}get duration(){const{resolved:t}=this;return t?hn(t.calculatedDuration):0}get time(){return hn(this.currentTime)}set time(t){t=Qe(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=hn(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=J0,onPlay:n,startTime:s}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),n&&n();const i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=s??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const ty=new Set(["opacity","clipPath","filter","transform"]);function ey(e,t,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:l="easeInOut",times:c}={}){const h={[t]:n};c&&(h.offset=c);const a=Cd(l,i);return Array.isArray(a)&&(h.easing=a),e.animate(h,{delay:s,duration:i,easing:Array.isArray(a)?"linear":a,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"})}const ny=Fa(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),_r=10,sy=2e4;function iy(e){return Za(e.type)||e.type==="spring"||!Sd(e.ease)}function ry(e,t){const n=new dl({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let s={done:!1,value:e[0]};const i=[];let r=0;for(;!s.done&&r<sy;)s=n.sample(r),i.push(s.value),r+=_r;return{times:void 0,keyframes:i,duration:r-_r,ease:"linear"}}const rf={anticipate:Dd,backInOut:Id,circInOut:zd};function oy(e){return e in rf}class Vc extends Kd{constructor(t){super(t);const{name:n,motionValue:s,element:i,keyframes:r}=this.options;this.resolver=new Jd(r,(o,l)=>this.onKeyframesResolved(o,l),n,s,i),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:s=300,times:i,ease:r,type:o,motionValue:l,name:c,startTime:h}=this.options;if(!l.owner||!l.owner.current)return!1;if(typeof r=="string"&&Ar()&&oy(r)&&(r=rf[r]),iy(this.options)){const{onComplete:u,onUpdate:f,motionValue:p,element:g,...d}=this.options,w=ry(t,d);t=w.keyframes,t.length===1&&(t[1]=t[0]),s=w.duration,i=w.times,r=w.ease,o="keyframes"}const a=ey(l.owner.current,c,t,{...this.options,duration:s,times:i,ease:r});return a.startTime=h??this.calcStartTime(),this.pendingTimeline?(Mc(a,this.pendingTimeline),this.pendingTimeline=void 0):a.onfinish=()=>{const{onComplete:u}=this.options;l.set(Gr(t,this.options,n)),u&&u(),this.cancel(),this.resolveFinishedPromise()},{animation:a,duration:s,times:i,type:o,ease:r,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return hn(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return hn(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:s}=n;s.currentTime=Qe(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:s}=n;s.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return Ae;const{animation:s}=n;Mc(s,t)}return Ae}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:s,duration:i,type:r,ease:o,times:l}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:h,onUpdate:a,onComplete:u,element:f,...p}=this.options,g=new dl({...p,keyframes:s,duration:i,type:r,ease:o,times:l,isGenerator:!0}),d=Qe(this.time);h.setWithVelocity(g.sample(d-_r).value,g.sample(d).value,_r)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:s,repeatDelay:i,repeatType:r,damping:o,type:l}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:h}=n.owner.getProps();return ny()&&s&&ty.has(s)&&!c&&!h&&!i&&r!=="mirror"&&o!==0&&l!=="inertia"}}const ay={type:"spring",stiffness:500,damping:25,restSpeed:10},ly=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),cy={type:"keyframes",duration:.8},hy={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},uy=(e,{keyframes:t})=>t.length>2?cy:rs.has(e)?e.startsWith("scale")?ly(t[1]):ay:hy;function dy({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:l,from:c,elapsed:h,...a}){return!!Object.keys(a).length}const fl=(e,t,n,s={},i,r)=>o=>{const l=Ka(s,e)||{},c=l.delay||s.delay||0;let{elapsed:h=0}=s;h=h-Qe(c);let a={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-h,onUpdate:f=>{t.set(f),l.onUpdate&&l.onUpdate(f)},onComplete:()=>{o(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:r?void 0:i};dy(l)||(a={...a,...uy(e,a)}),a.duration&&(a.duration=Qe(a.duration)),a.repeatDelay&&(a.repeatDelay=Qe(a.repeatDelay)),a.from!==void 0&&(a.keyframes[0]=a.from);let u=!1;if((a.type===!1||a.duration===0&&!a.repeatDelay)&&(a.duration=0,a.delay===0&&(u=!0)),u&&!r&&t.get()!==void 0){const f=Gr(a.keyframes,l);if(f!==void 0)return Bt.update(()=>{a.onUpdate(f),a.onComplete()}),new _g([])}return!r&&Vc.supports(a)?new Vc(a):new dl(a)};function fy({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function of(e,t,{delay:n=0,transitionOverride:s,type:i}={}){var r;let{transition:o=e.getDefaultTransition(),transitionEnd:l,...c}=t;s&&(o=s);const h=[],a=i&&e.animationState&&e.animationState.getState()[i];for(const u in c){const f=e.getValue(u,(r=e.latestValues[u])!==null&&r!==void 0?r:null),p=c[u];if(p===void 0||a&&fy(a,u))continue;const g={delay:n,...Ka(o||{},u)};let d=!1;if(window.MotionHandoffAnimation){const C=Rd(e);if(C){const x=window.MotionHandoffAnimation(C,u,Bt);x!==null&&(g.startTime=x,d=!0)}}ia(e,u),f.start(fl(u,f,p,e.shouldReduceMotion&&Td.has(u)?{type:!1}:g,e,d));const w=f.animation;w&&h.push(w)}return l&&Promise.all(h).then(()=>{Bt.update(()=>{l&&Hg(e,l)})}),h}function ua(e,t,n={}){var s;const i=qr(e,t,n.type==="exit"?(s=e.presenceContext)===null||s===void 0?void 0:s.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(r=n.transitionOverride);const o=i?()=>Promise.all(of(e,i,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(h=0)=>{const{delayChildren:a=0,staggerChildren:u,staggerDirection:f}=r;return my(e,t,a+h,u,f,n)}:()=>Promise.resolve(),{when:c}=r;if(c){const[h,a]=c==="beforeChildren"?[o,l]:[l,o];return h().then(()=>a())}else return Promise.all([o(),l(n.delay)])}function my(e,t,n=0,s=0,i=1,r){const o=[],l=(e.variantChildren.size-1)*s,c=i===1?(h=0)=>h*s:(h=0)=>l-h*s;return Array.from(e.variantChildren).sort(py).forEach((h,a)=>{h.notify("AnimationStart",t),o.push(ua(h,t,{...r,delay:n+c(a)}).then(()=>h.notify("AnimationComplete",t)))}),Promise.all(o)}function py(e,t){return e.sortNodePosition(t)}function gy(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const i=t.map(r=>ua(e,r,n));s=Promise.all(i)}else if(typeof t=="string")s=ua(e,t,n);else{const i=typeof t=="function"?qr(e,t,n.custom):t;s=Promise.all(of(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}const yy=Wa.length;function af(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?af(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<yy;n++){const s=Wa[n],i=e.props[s];(Ei(i)||i===!1)&&(t[s]=i)}return t}const by=[...Ba].reverse(),vy=Ba.length;function xy(e){return t=>Promise.all(t.map(({animation:n,options:s})=>gy(e,n,s)))}function wy(e){let t=xy(e),n=Oc(),s=!0;const i=c=>(h,a)=>{var u;const f=qr(e,a,c==="exit"?(u=e.presenceContext)===null||u===void 0?void 0:u.custom:void 0);if(f){const{transition:p,transitionEnd:g,...d}=f;h={...h,...d,...g}}return h};function r(c){t=c(e)}function o(c){const{props:h}=e,a=af(e.parent)||{},u=[],f=new Set;let p={},g=1/0;for(let w=0;w<vy;w++){const C=by[w],x=n[C],k=h[C]!==void 0?h[C]:a[C],S=Ei(k),T=C===c?x.isActive:null;T===!1&&(g=w);let P=k===a[C]&&k!==h[C]&&S;if(P&&s&&e.manuallyAnimateOnMount&&(P=!1),x.protectedKeys={...p},!x.isActive&&T===null||!k&&!x.prevProp||Ur(k)||typeof k=="boolean")continue;const I=Sy(x.prevProp,k);let L=I||C===c&&x.isActive&&!P&&S||w>g&&S,O=!1;const H=Array.isArray(k)?k:[k];let U=H.reduce(i(C),{});T===!1&&(U={});const{prevResolvedValues:q={}}=x,X={...q,...U},j=J=>{L=!0,f.has(J)&&(O=!0,f.delete(J)),x.needsAnimating[J]=!0;const nt=e.getValue(J);nt&&(nt.liveStyle=!1)};for(const J in X){const nt=U[J],it=q[J];if(p.hasOwnProperty(J))continue;let Q=!1;ea(nt)&&ea(it)?Q=!vd(nt,it):Q=nt!==it,Q?nt!=null?j(J):f.add(J):nt!==void 0&&f.has(J)?j(J):x.protectedKeys[J]=!0}x.prevProp=k,x.prevResolvedValues=U,x.isActive&&(p={...p,...U}),s&&e.blockInitialAnimation&&(L=!1),L&&(!(P&&I)||O)&&u.push(...H.map(J=>({animation:J,options:{type:C}})))}if(f.size){const w={};f.forEach(C=>{const x=e.getBaseTarget(C),k=e.getValue(C);k&&(k.liveStyle=!0),w[C]=x??null}),u.push({animation:w})}let d=!!u.length;return s&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(d=!1),s=!1,d?t(u):Promise.resolve()}function l(c,h){var a;if(n[c].isActive===h)return Promise.resolve();(a=e.variantChildren)===null||a===void 0||a.forEach(f=>{var p;return(p=f.animationState)===null||p===void 0?void 0:p.setActive(c,h)}),n[c].isActive=h;const u=o(c);for(const f in n)n[f].protectedKeys={};return u}return{animateChanges:o,setActive:l,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Oc(),s=!0}}}function Sy(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!vd(t,e):!1}function qn(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Oc(){return{animate:qn(!0),whileInView:qn(),whileHover:qn(),whileTap:qn(),whileDrag:qn(),whileFocus:qn(),exit:qn()}}class $n{constructor(t){this.isMounted=!1,this.node=t}update(){}}class Cy extends $n{constructor(t){super(t),t.animationState||(t.animationState=wy(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ur(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let ky=0;class My extends $n{constructor(){super(...arguments),this.id=ky++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const Ey={animation:{Feature:Cy},exit:{Feature:My}};function Pi(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function zi(e){return{point:{x:e.pageX,y:e.pageY}}}const Ty=e=>t=>el(t)&&e(t,zi(t));function yi(e,t,n,s){return Pi(e,t,Ty(n),s)}const Uc=(e,t)=>Math.abs(e-t);function Ay(e,t){const n=Uc(e.x,t.x),s=Uc(e.y,t.y);return Math.sqrt(n**2+s**2)}class lf{constructor(t,n,{transformPagePoint:s,contextWindow:i,dragSnapToOrigin:r=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const u=ko(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,p=Ay(u.offset,{x:0,y:0})>=3;if(!f&&!p)return;const{point:g}=u,{timestamp:d}=me;this.history.push({...g,timestamp:d});const{onStart:w,onMove:C}=this.handlers;f||(w&&w(this.lastMoveEvent,u),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,u)},this.handlePointerMove=(u,f)=>{this.lastMoveEvent=u,this.lastMoveEventInfo=Co(f,this.transformPagePoint),Bt.update(this.updatePoint,!0)},this.handlePointerUp=(u,f)=>{this.end();const{onEnd:p,onSessionEnd:g,resumeAnimation:d}=this.handlers;if(this.dragSnapToOrigin&&d&&d(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=ko(u.type==="pointercancel"?this.lastMoveEventInfo:Co(f,this.transformPagePoint),this.history);this.startEvent&&p&&p(u,w),g&&g(u,w)},!el(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.contextWindow=i||window;const o=zi(t),l=Co(o,this.transformPagePoint),{point:c}=l,{timestamp:h}=me;this.history=[{...c,timestamp:h}];const{onSessionStart:a}=n;a&&a(t,ko(l,this.history)),this.removeListeners=Li(yi(this.contextWindow,"pointermove",this.handlePointerMove),yi(this.contextWindow,"pointerup",this.handlePointerUp),yi(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Rn(this.updatePoint)}}function Co(e,t){return t?{point:t(e.point)}:e}function Hc(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ko({point:e},t){return{point:e,delta:Hc(e,cf(t)),offset:Hc(e,Ry(t)),velocity:Py(t,.1)}}function Ry(e){return e[0]}function cf(e){return e[e.length-1]}function Py(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=cf(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>Qe(t)));)n--;if(!s)return{x:0,y:0};const r=hn(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}const hf=1e-4,_y=1-hf,$y=1+hf,uf=.01,Ny=0-uf,Iy=0+uf;function Ne(e){return e.max-e.min}function Dy(e,t,n){return Math.abs(e-t)<=n}function qc(e,t,n,s=.5){e.origin=s,e.originPoint=Ht(t.min,t.max,e.origin),e.scale=Ne(n)/Ne(t),e.translate=Ht(n.min,n.max,e.origin)-e.originPoint,(e.scale>=_y&&e.scale<=$y||isNaN(e.scale))&&(e.scale=1),(e.translate>=Ny&&e.translate<=Iy||isNaN(e.translate))&&(e.translate=0)}function bi(e,t,n,s){qc(e.x,t.x,n.x,s?s.originX:void 0),qc(e.y,t.y,n.y,s?s.originY:void 0)}function Gc(e,t,n){e.min=n.min+t.min,e.max=e.min+Ne(t)}function Ly(e,t,n){Gc(e.x,t.x,n.x),Gc(e.y,t.y,n.y)}function Yc(e,t,n){e.min=t.min-n.min,e.max=e.min+Ne(t)}function vi(e,t,n){Yc(e.x,t.x,n.x),Yc(e.y,t.y,n.y)}function zy(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?Ht(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?Ht(n,e,s.max):Math.min(e,n)),e}function Xc(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Fy(e,{top:t,left:n,bottom:s,right:i}){return{x:Xc(e.x,n,i),y:Xc(e.y,t,s)}}function Qc(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function By(e,t){return{x:Qc(e.x,t.x),y:Qc(e.y,t.y)}}function Wy(e,t){let n=.5;const s=Ne(e),i=Ne(t);return i>s?n=Fs(t.min,t.max-s,e.min):s>i&&(n=Fs(e.min,e.max-i,t.min)),un(0,1,n)}function jy(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const da=.35;function Vy(e=da){return e===!1?e=0:e===!0&&(e=da),{x:Jc(e,"left","right"),y:Jc(e,"top","bottom")}}function Jc(e,t,n){return{min:Kc(e,t),max:Kc(e,n)}}function Kc(e,t){return typeof e=="number"?e:e[t]||0}const Zc=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ps=()=>({x:Zc(),y:Zc()}),th=()=>({min:0,max:0}),Kt=()=>({x:th(),y:th()});function Fe(e){return[e("x"),e("y")]}function df({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Oy({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Uy(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Mo(e){return e===void 0||e===1}function fa({scale:e,scaleX:t,scaleY:n}){return!Mo(e)||!Mo(t)||!Mo(n)}function Xn(e){return fa(e)||ff(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ff(e){return eh(e.x)||eh(e.y)}function eh(e){return e&&e!=="0%"}function $r(e,t,n){const s=e-n,i=t*s;return n+i}function nh(e,t,n,s,i){return i!==void 0&&(e=$r(e,i,s)),$r(e,n,s)+t}function ma(e,t=0,n=1,s,i){e.min=nh(e.min,t,n,s,i),e.max=nh(e.max,t,n,s,i)}function mf(e,{x:t,y:n}){ma(e.x,t.translate,t.scale,t.originPoint),ma(e.y,n.translate,n.scale,n.originPoint)}const sh=.999999999999,ih=1.0000000000001;function Hy(e,t,n,s=!1){const i=n.length;if(!i)return;t.x=t.y=1;let r,o;for(let l=0;l<i;l++){r=n[l],o=r.projectionDelta;const{visualElement:c}=r.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&$s(e,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,mf(e,o)),s&&Xn(r.latestValues)&&$s(e,r.latestValues))}t.x<ih&&t.x>sh&&(t.x=1),t.y<ih&&t.y>sh&&(t.y=1)}function _s(e,t){e.min=e.min+t,e.max=e.max+t}function rh(e,t,n,s,i=.5){const r=Ht(e.min,e.max,i);ma(e,t,n,r,s)}function $s(e,t){rh(e.x,t.x,t.scaleX,t.scale,t.originX),rh(e.y,t.y,t.scaleY,t.scale,t.originY)}function pf(e,t){return df(Uy(e.getBoundingClientRect(),t))}function qy(e,t,n){const s=pf(e,n),{scroll:i}=t;return i&&(_s(s.x,i.offset.x),_s(s.y,i.offset.y)),s}const gf=({current:e})=>e?e.ownerDocument.defaultView:null,Gy=new WeakMap;class Yy{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Kt(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const i=a=>{const{dragSnapToOrigin:u}=this.getProps();u?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(zi(a).point)},r=(a,u)=>{const{drag:f,dragPropagation:p,onDragStart:g}=this.getProps();if(f&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Wg(f),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Fe(w=>{let C=this.getAxisMotionValue(w).get()||0;if(Je.test(C)){const{projection:x}=this.visualElement;if(x&&x.layout){const k=x.layout.layoutBox[w];k&&(C=Ne(k)*(parseFloat(C)/100))}}this.originPoint[w]=C}),g&&Bt.postRender(()=>g(a,u)),ia(this.visualElement,"transform");const{animationState:d}=this.visualElement;d&&d.setActive("whileDrag",!0)},o=(a,u)=>{const{dragPropagation:f,dragDirectionLock:p,onDirectionLock:g,onDrag:d}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:w}=u;if(p&&this.currentDirection===null){this.currentDirection=Xy(w),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",u.point,w),this.updateAxis("y",u.point,w),this.visualElement.render(),d&&d(a,u)},l=(a,u)=>this.stop(a,u),c=()=>Fe(a=>{var u;return this.getAnimationState(a)==="paused"&&((u=this.getAxisMotionValue(a).animation)===null||u===void 0?void 0:u.play())}),{dragSnapToOrigin:h}=this.getProps();this.panSession=new lf(t,{onSessionStart:i,onStart:r,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,contextWindow:gf(this.visualElement)})}stop(t,n){const s=this.isDragging;if(this.cancel(),!s)return;const{velocity:i}=n;this.startAnimation(i);const{onDragEnd:r}=this.getProps();r&&Bt.postRender(()=>r(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:i}=this.getProps();if(!s||!tr(t,i,this.currentDirection))return;const r=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=zy(o,this.constraints[t],this.elastic[t])),r.set(o)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:s}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,r=this.constraints;n&&As(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&i?this.constraints=Fy(i.layoutBox,n):this.constraints=!1,this.elastic=Vy(s),r!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Fe(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=jy(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!As(t))return!1;const s=t.current;An(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=qy(s,i.root,this.visualElement.getTransformPagePoint());let o=By(i.layout.layoutBox,r);if(n){const l=n(Oy(o));this.hasMutatedConstraints=!!l,l&&(o=df(l))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},h=Fe(a=>{if(!tr(a,n,this.currentDirection))return;let u=c&&c[a]||{};o&&(u={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,g={type:"inertia",velocity:s?t[a]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...r,...u};return this.startAxisValueAnimation(a,g)});return Promise.all(h).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ia(this.visualElement,t),s.start(fl(t,s,0,n,this.visualElement,!1))}stopAnimation(){Fe(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Fe(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){Fe(n=>{const{drag:s}=this.getProps();if(!tr(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:l}=i.layout.layoutBox[n];r.set(t[n]-Ht(o,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!As(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Fe(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();i[o]=Wy({min:c,max:c},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Fe(o=>{if(!tr(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:h}=this.constraints[o];l.set(Ht(c,h,i[o]))})}addListeners(){if(!this.visualElement.current)return;Gy.set(this.visualElement,this);const t=this.visualElement.current,n=yi(t,"pointerdown",c=>{const{drag:h,dragListener:a=!0}=this.getProps();h&&a&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();As(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Bt.read(s);const o=Pi(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:h})=>{this.isDragging&&h&&(Fe(a=>{const u=this.getAxisMotionValue(a);u&&(this.originPoint[a]+=c[a].translate,u.set(u.get()+c[a].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=da,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:l}}}function tr(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Xy(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Qy extends $n{constructor(t){super(t),this.removeGroupControls=Ae,this.removeListeners=Ae,this.controls=new Yy(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ae}unmount(){this.removeGroupControls(),this.removeListeners()}}const oh=e=>(t,n)=>{e&&Bt.postRender(()=>e(t,n))};class Jy extends $n{constructor(){super(...arguments),this.removePointerDownListener=Ae}onPointerDown(t){this.session=new lf(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:gf(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:oh(t),onStart:oh(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&Bt.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=yi(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vr={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ah(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const oi={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(ct.test(e))e=parseFloat(e);else return e;const n=ah(e,t.target.x),s=ah(e,t.target.y);return`${n}% ${s}%`}},Ky={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=Pn.parse(e);if(i.length>5)return s;const r=Pn.createTransformer(e),o=typeof i[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=l,i[1+o]/=c;const h=Ht(l,c,.5);return typeof i[2+o]=="number"&&(i[2+o]/=h),typeof i[3+o]=="number"&&(i[3+o]/=h),r(i)}};class Zy extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=t;vg(tb),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),vr.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,o=s.projection;return o&&(o.isPresent=r,i||t.layoutDependency!==n||n===void 0?o.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?o.promote():o.relegate()||Bt.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Va.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function yf(e){const[t,n]=Zu(),s=m.useContext(Ia);return cn.jsx(Zy,{...e,layoutGroup:s,switchLayoutGroup:m.useContext(od),isPresent:t,safeToRemove:n})}const tb={borderRadius:{...oi,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:oi,borderTopRightRadius:oi,borderBottomLeftRadius:oi,borderBottomRightRadius:oi,boxShadow:Ky};function eb(e,t,n){const s=ve(e)?e:Ai(e);return s.start(fl("",s,t,n)),s.animation}function nb(e){return e instanceof SVGElement&&e.tagName!=="svg"}const sb=(e,t)=>e.depth-t.depth;class ib{constructor(){this.children=[],this.isDirty=!1}add(t){nl(this.children,t),this.isDirty=!0}remove(t){sl(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(sb),this.isDirty=!1,this.children.forEach(t)}}function rb(e,t){const n=Ke.now(),s=({timestamp:i})=>{const r=i-n;r>=t&&(Rn(s),e(r-t))};return Bt.read(s,!0),()=>Rn(s)}const bf=["TopLeft","TopRight","BottomLeft","BottomRight"],ob=bf.length,lh=e=>typeof e=="string"?parseFloat(e):e,ch=e=>typeof e=="number"||ct.test(e);function ab(e,t,n,s,i,r){i?(e.opacity=Ht(0,n.opacity!==void 0?n.opacity:1,lb(s)),e.opacityExit=Ht(t.opacity!==void 0?t.opacity:1,0,cb(s))):r&&(e.opacity=Ht(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,s));for(let o=0;o<ob;o++){const l=`border${bf[o]}Radius`;let c=hh(t,l),h=hh(n,l);if(c===void 0&&h===void 0)continue;c||(c=0),h||(h=0),c===0||h===0||ch(c)===ch(h)?(e[l]=Math.max(Ht(lh(c),lh(h),s),0),(Je.test(h)||Je.test(c))&&(e[l]+="%")):e[l]=h}(t.rotate||n.rotate)&&(e.rotate=Ht(t.rotate||0,n.rotate||0,s))}function hh(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const lb=vf(0,.5,Ld),cb=vf(.5,.95,Ae);function vf(e,t,n){return s=>s<e?0:s>t?1:n(Fs(e,t,s))}function uh(e,t){e.min=t.min,e.max=t.max}function ze(e,t){uh(e.x,t.x),uh(e.y,t.y)}function dh(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function fh(e,t,n,s,i){return e-=t,e=$r(e,1/n,s),i!==void 0&&(e=$r(e,1/i,s)),e}function hb(e,t=0,n=1,s=.5,i,r=e,o=e){if(Je.test(t)&&(t=parseFloat(t),t=Ht(o.min,o.max,t/100)-o.min),typeof t!="number")return;let l=Ht(r.min,r.max,s);e===r&&(l-=t),e.min=fh(e.min,t,n,l,i),e.max=fh(e.max,t,n,l,i)}function mh(e,t,[n,s,i],r,o){hb(e,t[n],t[s],t[i],t.scale,r,o)}const ub=["x","scaleX","originX"],db=["y","scaleY","originY"];function ph(e,t,n,s){mh(e.x,t,ub,n?n.x:void 0,s?s.x:void 0),mh(e.y,t,db,n?n.y:void 0,s?s.y:void 0)}function gh(e){return e.translate===0&&e.scale===1}function xf(e){return gh(e.x)&&gh(e.y)}function yh(e,t){return e.min===t.min&&e.max===t.max}function fb(e,t){return yh(e.x,t.x)&&yh(e.y,t.y)}function bh(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function wf(e,t){return bh(e.x,t.x)&&bh(e.y,t.y)}function vh(e){return Ne(e.x)/Ne(e.y)}function xh(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class mb{constructor(){this.members=[]}add(t){nl(this.members,t),t.scheduleRender()}remove(t){if(sl(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function pb(e,t,n){let s="";const i=e.x.translate/t.x,r=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:h,rotate:a,rotateX:u,rotateY:f,skewX:p,skewY:g}=n;h&&(s=`perspective(${h}px) ${s}`),a&&(s+=`rotate(${a}deg) `),u&&(s+=`rotateX(${u}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}deg) `),g&&(s+=`skewY(${g}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(s+=`scale(${l}, ${c})`),s||"none"}const Qn={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},di=typeof window<"u"&&window.MotionDebug!==void 0,Eo=["","X","Y","Z"],gb={visibility:"hidden"},wh=1e3;let yb=0;function To(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function Sf(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Rd(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Bt,!(i||r))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&Sf(s)}function Cf({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},l=t==null?void 0:t()){this.id=yb++,this.animationId=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.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,di&&(Qn.totalNodes=Qn.resolvedTargetDeltas=Qn.recalculatedProjection=0),this.nodes.forEach(xb),this.nodes.forEach(Mb),this.nodes.forEach(Eb),this.nodes.forEach(wb),di&&window.MotionDebug.record(Qn)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new ib)}addEventListener(o,l){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new il),this.eventHandlers.get(o).add(l)}notifyListeners(o,...l){const c=this.eventHandlers.get(o);c&&c.notify(...l)}hasListeners(o){return this.eventHandlers.has(o)}mount(o,l=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=nb(o),this.instance=o;const{layoutId:c,layout:h,visualElement:a}=this.options;if(a&&!a.current&&a.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),l&&(h||c)&&(this.isLayoutDirty=!0),e){let u;const f=()=>this.root.updateBlockedByResize=!1;e(o,()=>{this.root.updateBlockedByResize=!0,u&&u(),u=rb(f,250),vr.hasAnimatedSinceResize&&(vr.hasAnimatedSinceResize=!1,this.nodes.forEach(Ch))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&a&&(c||h)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:f,hasRelativeTargetChanged:p,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const d=this.options.transition||a.getDefaultTransition()||_b,{onLayoutAnimationStart:w,onLayoutAnimationComplete:C}=a.getProps(),x=!this.targetLayout||!wf(this.targetLayout,g)||p,k=!f&&p;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||k||f&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(u,k);const S={...Ka(d,"layout"),onPlay:w,onComplete:C};(a.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S)}else f||Ch(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Rn(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(Tb),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Sf(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let a=0;a<this.path.length;a++){const u=this.path[a];u.shouldResetTransform=!0,u.updateScroll("snapshot"),u.options.layoutRoot&&u.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Sh);return}this.isUpdating||this.nodes.forEach(Cb),this.isUpdating=!1,this.nodes.forEach(kb),this.nodes.forEach(bb),this.nodes.forEach(vb),this.clearAllSnapshots();const l=Ke.now();me.delta=un(0,1e3/60,l-me.timestamp),me.timestamp=l,me.isProcessing=!0,yo.update.process(me),yo.preRender.process(me),yo.render.process(me),me.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Va.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Sb),this.sharedNodes.forEach(Ab)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Bt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Bt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Kt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(l=!1),l){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!xf(this.projectionDelta),c=this.getTransformTemplate(),h=c?c(this.latestValues,""):void 0,a=h!==this.prevTransformTemplateValue;o&&(l||Xn(this.latestValues)||a)&&(i(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return o&&(c=this.removeTransform(c)),$b(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var o;const{visualElement:l}=this.options;if(!l)return Kt();const c=l.measureViewportBox();if(!(((o=this.scroll)===null||o===void 0?void 0:o.wasRoot)||this.path.some(Nb))){const{scroll:a}=this.root;a&&(_s(c.x,a.offset.x),_s(c.y,a.offset.y))}return c}removeElementScroll(o){var l;const c=Kt();if(ze(c,o),!((l=this.scroll)===null||l===void 0)&&l.wasRoot)return c;for(let h=0;h<this.path.length;h++){const a=this.path[h],{scroll:u,options:f}=a;a!==this.root&&u&&f.layoutScroll&&(u.wasRoot&&ze(c,o),_s(c.x,u.offset.x),_s(c.y,u.offset.y))}return c}applyTransform(o,l=!1){const c=Kt();ze(c,o);for(let h=0;h<this.path.length;h++){const a=this.path[h];!l&&a.options.layoutScroll&&a.scroll&&a!==a.root&&$s(c,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),Xn(a.latestValues)&&$s(c,a.latestValues)}return Xn(this.latestValues)&&$s(c,this.latestValues),c}removeTransform(o){const l=Kt();ze(l,o);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!h.instance||!Xn(h.latestValues))continue;fa(h.latestValues)&&h.updateSnapshot();const a=Kt(),u=h.measurePageBox();ze(a,u),ph(l,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,a)}return Xn(this.latestValues)&&ph(l,this.latestValues),l}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}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!==me.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var l;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const h=!!this.resumingFrom||this!==c;if(!(o||h&&this.isSharedProjectionDirty||this.isProjectionDirty||!((l=this.parent)===null||l===void 0)&&l.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:f}=this.options;if(!(!this.layout||!(u||f))){if(this.resolvedRelativeTargetAt=me.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Kt(),this.relativeTargetOrigin=Kt(),vi(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),ze(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Kt(),this.targetWithTransforms=Kt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ly(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ze(this.target,this.layout.layoutBox),mf(this.target,this.targetDelta)):ze(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Kt(),this.relativeTargetOrigin=Kt(),vi(this.relativeTargetOrigin,this.target,p.target),ze(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}di&&Qn.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||fa(this.parent.latestValues)||ff(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var o;const l=this.getLead(),c=!!this.resumingFrom||this!==l;let h=!0;if((this.isProjectionDirty||!((o=this.parent)===null||o===void 0)&&o.isProjectionDirty)&&(h=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(h=!1),this.resolvedRelativeTargetAt===me.timestamp&&(h=!1),h)return;const{layout:a,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(a||u))return;ze(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,p=this.treeScale.y;Hy(this.layoutCorrected,this.treeScale,this.path,c),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=Kt());const{target:g}=l;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(dh(this.prevProjectionDelta.x,this.projectionDelta.x),dh(this.prevProjectionDelta.y,this.projectionDelta.y)),bi(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==p||!xh(this.projectionDelta.x,this.prevProjectionDelta.x)||!xh(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g)),di&&Qn.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var l;if((l=this.options.visualElement)===null||l===void 0||l.scheduleRender(),o){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ps(),this.projectionDelta=Ps(),this.projectionDeltaWithTransform=Ps()}setAnimationOrigin(o,l=!1){const c=this.snapshot,h=c?c.latestValues:{},a={...this.latestValues},u=Ps();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const f=Kt(),p=c?c.source:void 0,g=this.layout?this.layout.source:void 0,d=p!==g,w=this.getStack(),C=!w||w.members.length<=1,x=!!(d&&!C&&this.options.crossfade===!0&&!this.path.some(Pb));this.animationProgress=0;let k;this.mixTargetDelta=S=>{const T=S/1e3;kh(u.x,o.x,T),kh(u.y,o.y,T),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(vi(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Rb(this.relativeTarget,this.relativeTargetOrigin,f,T),k&&fb(this.relativeTarget,k)&&(this.isProjectionDirty=!1),k||(k=Kt()),ze(k,this.relativeTarget)),d&&(this.animationValues=a,ab(a,h,this.latestValues,T,x,C)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=T},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Rn(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Bt.update(()=>{vr.hasAnimatedSinceResize=!0,this.currentAnimation=eb(0,wh,{...o,onUpdate:l=>{this.mixTargetDelta(l),o.onUpdate&&o.onUpdate(l)},onComplete:()=>{o.onComplete&&o.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);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(wh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:l,target:c,layout:h,latestValues:a}=o;if(!(!l||!c||!h)){if(this!==o&&this.layout&&h&&kf(this.options.animationType,this.layout.layoutBox,h.layoutBox)){c=this.target||Kt();const u=Ne(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+u;const f=Ne(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+f}ze(l,c),$s(l,a),bi(this.projectionDeltaWithTransform,this.layoutCorrected,l,a)}}registerSharedNode(o,l){this.sharedNodes.has(o)||this.sharedNodes.set(o,new mb),this.sharedNodes.get(o).add(l);const h=l.options.initialPromotionConfig;l.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(l):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:l}=this.options;return l?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:l}=this.options;return l?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:l,preserveFollowOpacity:c}={}){const h=this.getStack();h&&h.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let l=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const h={};c.z&&To("z",o,h,this.animationValues);for(let a=0;a<Eo.length;a++)To(`rotate${Eo[a]}`,o,h,this.animationValues),To(`skew${Eo[a]}`,o,h,this.animationValues);o.render();for(const a in h)o.setStaticValue(a,h[a]),this.animationValues&&(this.animationValues[a]=h[a]);o.scheduleRender()}getProjectionStyles(o){var l,c;if(!this.instance||this.isSVG)return;if(!this.isVisible)return gb;const h={visibility:""},a=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,h.opacity="",h.pointerEvents=yr(o==null?void 0:o.pointerEvents)||"",h.transform=a?a(this.latestValues,""):"none",h;const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){const d={};return this.options.layoutId&&(d.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,d.pointerEvents=yr(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Xn(this.latestValues)&&(d.transform=a?a({},""):"none",this.hasProjected=!1),d}const f=u.animationValues||u.latestValues;this.applyTransformsToTarget(),h.transform=pb(this.projectionDeltaWithTransform,this.treeScale,f),a&&(h.transform=a(f,h.transform));const{x:p,y:g}=this.projectionDelta;h.transformOrigin=`${p.origin*100}% ${g.origin*100}% 0`,u.animationValues?h.opacity=u===this?(c=(l=f.opacity)!==null&&l!==void 0?l:this.latestValues.opacity)!==null&&c!==void 0?c:1:this.preserveOpacity?this.latestValues.opacity:f.opacityExit:h.opacity=u===this?f.opacity!==void 0?f.opacity:"":f.opacityExit!==void 0?f.opacityExit:0;for(const d in Tr){if(f[d]===void 0)continue;const{correct:w,applyTo:C}=Tr[d],x=h.transform==="none"?f[d]:w(f[d],u);if(C){const k=C.length;for(let S=0;S<k;S++)h[C[S]]=x}else h[d]=x}return this.options.layoutId&&(h.pointerEvents=u===this?yr(o==null?void 0:o.pointerEvents)||"":"none"),h}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var l;return(l=o.currentAnimation)===null||l===void 0?void 0:l.stop()}),this.root.nodes.forEach(Sh),this.root.sharedNodes.clear()}}}function bb(e){e.updateLayout()}function vb(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:s,measuredBox:i}=e.layout,{animationType:r}=e.options,o=n.source!==e.layout.source;r==="size"?Fe(u=>{const f=o?n.measuredBox[u]:n.layoutBox[u],p=Ne(f);f.min=s[u].min,f.max=f.min+p}):kf(r,n.layoutBox,s)&&Fe(u=>{const f=o?n.measuredBox[u]:n.layoutBox[u],p=Ne(s[u]);f.max=f.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+p)});const l=Ps();bi(l,s,n.layoutBox);const c=Ps();o?bi(c,e.applyTransform(i,!0),n.measuredBox):bi(c,s,n.layoutBox);const h=!xf(l);let a=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:f,layout:p}=u;if(f&&p){const g=Kt();vi(g,n.layoutBox,f.layoutBox);const d=Kt();vi(d,s,p.layoutBox),wf(g,d)||(a=!0),u.options.layoutRoot&&(e.relativeTarget=d,e.relativeTargetOrigin=g,e.relativeParent=u)}}}e.notifyListeners("didUpdate",{layout:s,snapshot:n,delta:c,layoutDelta:l,hasLayoutChanged:h,hasRelativeTargetChanged:a})}else if(e.isLead()){const{onExitComplete:s}=e.options;s&&s()}e.options.transition=void 0}function xb(e){di&&Qn.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function wb(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Sb(e){e.clearSnapshot()}function Sh(e){e.clearMeasurements()}function Cb(e){e.isLayoutDirty=!1}function kb(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Ch(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Mb(e){e.resolveTargetDelta()}function Eb(e){e.calcProjection()}function Tb(e){e.resetSkewAndRotation()}function Ab(e){e.removeLeadSnapshot()}function kh(e,t,n){e.translate=Ht(t.translate,0,n),e.scale=Ht(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Mh(e,t,n,s){e.min=Ht(t.min,n.min,s),e.max=Ht(t.max,n.max,s)}function Rb(e,t,n,s){Mh(e.x,t.x,n.x,s),Mh(e.y,t.y,n.y,s)}function Pb(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const _b={duration:.45,ease:[.4,0,.1,1]},Eh=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Th=Eh("applewebkit/")&&!Eh("chrome/")?Math.round:Ae;function Ah(e){e.min=Th(e.min),e.max=Th(e.max)}function $b(e){Ah(e.x),Ah(e.y)}function kf(e,t,n){return e==="position"||e==="preserve-aspect"&&!Dy(vh(t),vh(n),.2)}function Nb(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const Ib=Cf({attachResizeListener:(e,t)=>Pi(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Ao={current:void 0},Mf=Cf({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Ao.current){const e=new Ib({});e.mount(window),e.setOptions({layoutScroll:!0}),Ao.current=e}return Ao.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Db={pan:{Feature:Jy},drag:{Feature:Qy,ProjectionNode:Mf,MeasureLayout:yf}};function Rh(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&Bt.postRender(()=>r(t,zi(t)))}class Lb extends $n{mount(){const{current:t}=this.node;t&&(this.unmount=Dg(t,n=>(Rh(this.node,n,"Start"),s=>Rh(this.node,s,"End"))))}unmount(){}}class zb extends $n{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=Li(Pi(this.node.current,"focus",()=>this.onFocus()),Pi(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ph(e,t,n){const{props:s}=e;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&Bt.postRender(()=>r(t,zi(t)))}class Fb extends $n{mount(){const{current:t}=this.node;t&&(this.unmount=Bg(t,n=>(Ph(this.node,n,"Start"),(s,{success:i})=>Ph(this.node,s,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const pa=new WeakMap,Ro=new WeakMap,Bb=e=>{const t=pa.get(e.target);t&&t(e)},Wb=e=>{e.forEach(Bb)};function jb({root:e,...t}){const n=e||document;Ro.has(n)||Ro.set(n,{});const s=Ro.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(Wb,{root:e,...t})),s[i]}function Vb(e,t,n){const s=jb(t);return pa.set(e,n),s.observe(e),()=>{pa.delete(e),s.unobserve(e)}}const Ob={some:0,all:1};class Ub extends $n{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Ob[i]},l=c=>{const{isIntersecting:h}=c;if(this.isInView===h||(this.isInView=h,r&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:a,onViewportLeave:u}=this.node.getProps(),f=h?a:u;f&&f(c)};return Vb(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Hb(t,n))&&this.startObserver()}unmount(){}}function Hb({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const qb={inView:{Feature:Ub},tap:{Feature:Fb},focus:{Feature:zb},hover:{Feature:Lb}},Gb={layout:{ProjectionNode:Mf,MeasureLayout:yf}},ga={current:null},Ef={current:!1};function Yb(){if(Ef.current=!0,!!za)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>ga.current=e.matches;e.addListener(t),t()}else ga.current=!1}const Xb=[...Qd,be,Pn],Qb=e=>Xb.find(Xd(e)),_h=new WeakMap;function Jb(e,t,n){for(const s in t){const i=t[s],r=n[s];if(ve(i))e.addValue(s,i),process.env.NODE_ENV==="development"&&Vr(i.version==="11.18.2",`Attempting to mix Motion versions ${i.version} with 11.18.2 may not work as expected.`);else if(ve(r))e.addValue(s,Ai(i,{owner:e}));else if(r!==i)if(e.hasValue(s)){const o=e.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(s);e.addValue(s,Ai(o!==void 0?o:i,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const $h=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Kb{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=hl,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=()=>{const p=Ke.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,Bt.render(this.render,!1,!0))};const{latestValues:c,renderState:h,onUpdate:a}=o;this.onUpdate=a,this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=h,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=l,this.blockInitialAnimation=!!r,this.isControllingVariants=Hr(n),this.isVariantNode=id(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:u,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in f){const g=f[p];c[p]!==void 0&&ve(g)&&g.set(c[p],!1)}}mount(t){this.current=t,_h.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Ef.current||Yb(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ga.current,process.env.NODE_ENV!=="production"&&Vr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected."),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){_h.delete(this.current),this.projection&&this.projection.unmount(),Rn(this.notifyUpdate),Rn(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=rs.has(t),i=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&Bt.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0)}),r=n.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Bs){const n=Bs[t];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[t]&&i&&s(this.props)&&(this.features[t]=new i(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Kt()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<$h.length;s++){const i=$h[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=t[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=Jb(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Ai(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){var s;let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(s=this.getBaseTargetFromProps(this.props,t))!==null&&s!==void 0?s:this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(Gd(i)||Fd(i))?i=parseFloat(i):!Qb(i)&&Pn.test(n)&&(i=Ud(t,n)),this.setBaseTarget(t,ve(i)?i.get():i)),ve(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:s}=this.props;let i;if(typeof s=="string"||typeof s=="object"){const o=Ua(this.props,s,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);o&&(i=o[t])}if(s&&i!==void 0)return i;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!ve(r)?r:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new il),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Tf extends Kb{constructor(){super(...arguments),this.KeyframeResolver=Jd}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;ve(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Zb(e){return window.getComputedStyle(e)}class tv extends Tf{constructor(){super(...arguments),this.type="html",this.renderInstance=fd}readValueFromInstance(t,n){if(rs.has(n)){const s=cl(n);return s&&s.default||0}else{const s=Zb(t),i=(hd(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return pf(t,n)}build(t,n,s){Ga(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Ja(t,n,s)}}class ev extends Tf{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Kt}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(rs.has(n)){const s=cl(n);return s&&s.default||0}return n=md.has(n)?n:ja(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return yd(t,n,s)}build(t,n,s){Ya(t,n,this.isSVGTag,s.transformTemplate)}renderInstance(t,n,s,i){pd(t,n,s,i)}mount(t){this.isSVGTag=Qa(t.tagName),super.mount(t)}}const nv=(e,t)=>Oa(e)?new ev(t):new tv(t,{allowProjection:e!==m.Fragment}),sv=Ag({...Ey,...qb,...Db,...Gb},nv),Nr=Op(sv),iv={div:"div",span:"span",p:"p",hr:"hr",a:"a",strong:"strong",em:"em",del:"del",li:"li",ul:"ul",ol:"ol",form:"form",img:"img",header:"header",footer:"footer",section:"section",nav:"nav",main:"main",article:"article",aside:"aside",figure:"figure",figcaption:"figcaption",th:"th",td:"td",caption:"caption",blockquote:"blockquote",address:"address",time:"time",legend:"legend",label:"label",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",code:"code"},rv=new Set(["motion","initial","animate","exit","transition","variants","whileHover","whileTap","whileFocus","whileInView","animateLayout"]);function E(e,t,...n){const{style:s,className:i,...r}=t||{};if(r.motion){const l={};for(const h of rv)if(h in r){const a=h==="animateLayout"?"layout":h;let u=r[h];a==="transition"&&u&&typeof u=="object"&&(u={...u,repeat:Math.max(0,Number(u.repeat)||0)}),l[a]=u,delete r[h]}const c=Nr[e]||Nr.div;return m.createElement(c,{...r,className:i,style:s||{},...l},...n)}delete r.animateLayout;const o=iv[e];return o?m.createElement(o,{...r,className:i,style:s||{}},...n):m.createElement(e,{...r,className:i,style:s||{}},...n)}const ov={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Af={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Rf=["base","sm","md","lg","xl","2xl"],oe={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},er={xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem","6xl":"3.75rem","7xl":"4.5rem","8xl":"6rem","9xl":"8rem"},Nh={"1/2":"50%","1/3":"33.333333%","2/3":"66.666667%","1/4":"25%","2/4":"50%","3/4":"75%","1/5":"20%","2/5":"40%","3/5":"60%","4/5":"80%","1/6":"16.666667%","2/6":"33.333333%","3/6":"50%","4/6":"66.666667%","5/6":"83.333333%","1/12":"8.333333%","2/12":"16.666667%","3/12":"25%","4/12":"33.333333%","5/12":"41.666667%","6/12":"50%","7/12":"58.333333%","8/12":"66.666667%","9/12":"75%","10/12":"83.333333%","11/12":"91.666667%",full:"100%",auto:"auto",screen:"100vw",fit:"fit-content",max:"max-content",min:"min-content"},nr={"flex-row":"row","flex-row-reverse":"row-reverse","flex-col":"column","flex-col-reverse":"column-reverse"},sr={"items-start":"flex-start","items-end":"flex-end","items-center":"center","items-baseline":"baseline","items-stretch":"stretch"},ir={"justify-start":"flex-start","justify-end":"flex-end","justify-center":"center","justify-between":"space-between","justify-around":"space-around","justify-evenly":"space-evenly"},rr={"rounded-none":"0px","rounded-sm":"0.125rem",rounded:"0.25rem","rounded-md":"0.375rem","rounded-lg":"0.5rem","rounded-xl":"0.75rem","rounded-2xl":"1rem","rounded-3xl":"1.5rem","rounded-full":"9999px"},av=["hidden","block","flex","grid","inline","inline-block","inline-flex"];function lv(e,t,n,s){const i=new Map,r=e.split(/\s+/).filter(Boolean);for(const o of r){const l=new RegExp(n.source).exec(o);if(l){i.set(l[1],s(l));continue}const c=new RegExp(t.source).exec(o);c&&i.set("base",s([null,null,c[1]]))}return i}function Pf(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(flex-row|flex-row-reverse|flex-col|flex-col-reverse)$/);if(i&&nr[i[2]]){t.set(i[1],nr[i[2]]);continue}nr[s]&&t.set("base",nr[s])}return t}function _f(e){return lv(e,/^gap-(\d+(?:\.\d+)?)$/,/^(sm|md|lg|xl|2xl):gap-(\d+(?:\.\d+)?)$/,t=>oe[t[2]]||`${t[2]}px`)}function $f(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):w-(.+)$/);if(i){const o=Nh[i[2]]||oe[i[2]]||i[2];o&&t.set(i[1],o);continue}const r=s.match(/^w-(.+)$/);if(r){const o=Nh[r[1]]||oe[r[1]]||r[1];o&&t.set("base",o)}}return t}function Nf(e){const t=new Map,n=new Map,s=new Map,i=new Map,r=new Map,o=new Map,l=new Map,c=e.split(/\s+/).filter(Boolean);for(const h of c)for(const[a,u]of[["m-",t],["mt-",n],["mr-",s],["mb-",i],["ml-",r],["mx-",o],["my-",l]]){const f=h.match(new RegExp(`^(sm|md|lg|xl|2xl):${a}(\\d+(?:\\.\\d+)?)$`));if(f&&oe[f[2]]){u.set(f[1],oe[f[2]]);break}const p=h.match(new RegExp(`^${a}(\\d+(?:\\.\\d+)?)$`));if(p&&oe[p[1]]){u.set("base",oe[p[1]]);break}}return{all:t,t:n,r:s,b:i,l:r,x:o,y:l}}function If(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(items-start|items-end|items-center|items-baseline|items-stretch)$/);if(i&&sr[i[2]]){t.set(i[1],sr[i[2]]);continue}sr[s]&&t.set("base",sr[s])}return t}function Df(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(justify-start|justify-end|justify-center|justify-between|justify-around|justify-evenly)$/);if(i&&ir[i[2]]){t.set(i[1],ir[i[2]]);continue}ir[s]&&t.set("base",ir[s])}return t}function Lf(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(rounded-none|rounded-sm|rounded|rounded-md|rounded-lg|rounded-xl|rounded-2xl|rounded-3xl|rounded-full)$/);if(i&&rr[i[2]]){t.set(i[1],rr[i[2]]);continue}rr[s]&&t.set("base",rr[s])}return t}function ml(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(hidden|block|flex|grid|inline|inline-block|inline-flex)$/);if(i){t.set(i[1],i[2]==="hidden"?"none":i[2]);continue}av.includes(s)&&t.set("base",s==="hidden"?"none":s)}return t}function pl(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):grid-cols-(\d+)$/);if(i){t.set(i[1],parseInt(i[2],10));continue}const r=s.match(/^grid-cols-(\d+)$/);r&&t.set("base",parseInt(r[1],10))}return t}function gl(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);if(i&&er[i[2]]){t.set(i[1],er[i[2]]);continue}const r=s.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);r&&er[r[1]]&&t.set("base",er[r[1]])}return t}function yl(e){const t=new Map,n=new Map,s=new Map,i=e.split(/\s+/).filter(Boolean);for(const r of i){const o=r.match(/^(sm|md|lg|xl|2xl):px-(\d+(?:\.\d+)?)$/);if(o&&oe[o[2]]){t.set(o[1],oe[o[2]]);continue}const l=r.match(/^px-(\d+(?:\.\d+)?)$/);if(l&&oe[l[1]]){t.set("base",oe[l[1]]);continue}const c=r.match(/^(sm|md|lg|xl|2xl):py-(\d+(?:\.\d+)?)$/);if(c&&oe[c[2]]){n.set(c[1],oe[c[2]]);continue}const h=r.match(/^py-(\d+(?:\.\d+)?)$/);if(h&&oe[h[1]]){n.set("base",oe[h[1]]);continue}const a=r.match(/^(sm|md|lg|xl|2xl):p-(\d+(?:\.\d+)?)$/);if(a&&oe[a[2]]){s.set(a[1],oe[a[2]]);continue}const u=r.match(/^p-(\d+(?:\.\d+)?)$/);u&&oe[u[1]]&&s.set("base",oe[u[1]])}return{px:t,py:n,p:s}}function ya(e){return e.flexDirection.size>0||e.gap.size>0||e.width.size>0||e.alignItems.size>0||e.justifyContent.size>0||e.padding.px.size>0||e.padding.py.size>0||e.padding.p.size>0||e.display.size>0||e.gridCols.size>0||e.textSize.size>0||e.borderRadius.size>0||e.margin.all.size>0||e.margin.t.size>0||e.margin.r.size>0||e.margin.b.size>0||e.margin.l.size>0||e.margin.x.size>0||e.margin.y.size>0}function ba(e){return{flexDirection:Pf(e),gap:_f(e),width:$f(e),margin:Nf(e),alignItems:If(e),justifyContent:Df(e),padding:yl(e),display:ml(e),gridCols:pl(e),textSize:gl(e),borderRadius:Lf(e),any:!1}}const _i=ov;function cv(e){return pl(e)}function hv(e,t){let n=e.get("base")??1;const s=["2xl","xl","lg","md","sm"];if(t<=0){for(const i of s)if(e.has(i))return e.get(i);return n}for(const i of["sm","md","lg","xl","2xl"])t>=(_i[i]||0)&&e.has(i)&&(n=e.get(i));return n}function bl(e){return gl(e)}function ht(e,t,n){let s=e.get("base")??n;for(const i of["sm","md","lg","xl","2xl"])t>=(_i[i]||0)&&e.has(i)&&(s=e.get(i));return s}function Fi(e){return yl(e)}function Gs(e){return ml(e)}function zf(e){const[t,n]=m.useState(()=>{var i;return((i=e.current)==null?void 0:i.offsetWidth)??0}),s=m.useRef(t);return m.useEffect(()=>{const i=e.current;if(!i)return;const r=i.offsetWidth;r>0&&r!==s.current&&(s.current=r,n(r));const o=new ResizeObserver(l=>{for(const c of l){const h=Math.round(c.contentRect.width);h>0&&h!==s.current&&(s.current=h,n(h))}});return o.observe(i),()=>{o.disconnect()}},[e]),t}function uv(e,t,n){var h,a,u;const i=(Array.isArray(t.tabItems)?t.tabItems:Array.isArray(t.tabs)?t.tabs:[]).filter(f=>!f.condition||!e.evaluateCondition||e.evaluateCondition(f.condition));if(i.length===0)return null;const r=`__tab_${n}`,o=e.sceneData[r]??(t.defaultTab||0),l={width:"100%",display:"flex",flexDirection:"column",...t.className?((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className):{}},c=e.getCommonProps(n,l,t);return m.createElement("div",{key:n,...c},m.createElement("div",{style:{display:"flex",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,gap:"0"}},i.map((f,p)=>m.createElement("button",{key:`${n}-tab-${p}`,onClick:()=>e.setSceneData(g=>({...g,[r]:p})),style:{padding:"8px 16px",fontSize:"13px",fontWeight:o===p?600:400,color:o===p?e.cfg.colors.primary:e.cfg.colors.textMuted,borderBottom:o===p?`2px solid ${e.cfg.colors.primary}`:"2px solid transparent",background:"none",border:"none",borderBottomStyle:"solid",borderBottomWidth:"2px",borderBottomColor:o===p?e.cfg.colors.primary:"transparent",cursor:"pointer",transition:e.cfg.effects.transition}},f.label||f.title))),m.createElement("div",{style:{padding:"12px 0"}},(Array.isArray((a=i[o])==null?void 0:a.content)?i[o].content:Array.isArray((u=i[o])==null?void 0:u.children)?i[o].children:[]).map((f,p)=>e.renderComponent(f,p,`${n}-tabcontent-${o}`))))}function dv(e,t,n){var o;Array.isArray(t.items)&&!Array.isArray(t.accordionItems)&&(t.accordionItems=t.items);const s=Array.isArray(t.accordionItems)?t.accordionItems:[];if(s.length===0)return null;const i={width:"100%",display:"flex",flexDirection:"column",gap:"1px",...t.className?((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...r},s.map((l,c)=>{const h=`__acc_${n}_${c}`,a=e.sceneData[h]??(l.defaultOpen||!1);return m.createElement("div",{key:`${n}-acc-${c}`},m.createElement("button",{onClick:()=>e.setSceneData(u=>({...u,[h]:!a})),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",background:"none",border:"none",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.textSecondary,fontSize:e.cfg.typography.baseFontSize,fontWeight:500,cursor:"pointer",transition:e.cfg.effects.transition}},E("span",{style:{display:"flex",alignItems:"center",gap:"8px"}},l.icon?e.renderIcon(l.icon,14,{color:e.cfg.colors.primary}):null,E("span",null,l.title)),E("span",{style:{transform:a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s",fontSize:"24px"}},"▾")),m.createElement(Dp,{initial:!1},a&&m.createElement(Nr.div,{key:`${n}-acc-body-${c}`,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.3,ease:"easeInOut"},opacity:{duration:.25}},style:{overflow:"hidden"}},m.createElement("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:"8px"}},(Array.isArray(l.content)?l.content:typeof l.content=="string"?[{type:"text",text:l.content}]:Array.isArray(l.children)?l.children:[]).map((f,p)=>e.renderComponent(f,p,`${n}-acc-${c}-content`))))))}))}function fv(e,t,n){var p,g,d,w,C;const s=(p=e.paginationState)==null?void 0:p[n],i=t.pagination===!0&&s&&s.total>s.limit,r=t.pagination==="scroll",o=s?Math.ceil(s.total/s.limit):0,l=t.className||"flex flex-col gap-3 w-full",c=((g=e.parseClassNameResponsive)==null?void 0:g.call(e,l,n))??e.parseClassName(l);t.rawStyle&&Object.assign(c,t.rawStyle);const h=(d=e.loading)==null?void 0:d[n],a=(w=e.listData)==null?void 0:w[n],u=Array.isArray(a)?a:[],f=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{};return m.createElement("div",{key:n,className:l,style:c,"data-component-key":n,...f},h&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):m.createElement("div",{className:"flex justify-center py-4"},E("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),!h&&u.length===0&&t.emptyComponent&&e.renderComponent(t.emptyComponent,0,`${n}-empty`),!h&&t.selectable&&e.sceneData._selectMode&&u.length>0&&E("div",{key:`${n}-sel-hdr`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:((C=t.selectionStyle)==null?void 0:C.headerPadding)||"0.5rem 2rem"}},E("button",{type:"button",onClick:()=>{const x=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[],k=u.map((T,P)=>String(T.id||P)),S=k.length>0&&k.every(T=>x.includes(T));e.setSceneData(T=>({...T,_selIds:S?[]:k}))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textSecondary,fontSize:"12px",fontFamily:"inherit",padding:"4px 0"}},(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).filter(x=>u.some(k=>String(k.id)===x)).length===u.filter(x=>x.id).length&&u.length>0?"Deselect all":"Select all"),(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length>0?E("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},...(Array.isArray(t.selectActions)?t.selectActions:[]).map((x,k)=>E("button",{key:k,type:"button",onClick:()=>{var T;const S=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[];S.length!==0&&((T=e.runBulkSelectAction)==null||T.call(e,x,t.dataSource,n,S))},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,transition:"all 0.15s ease",padding:"0"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=e.cfg.colors.border,S.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent",S.currentTarget.style.color=e.cfg.colors.textSecondary}},e.renderIcon(x.icon,12))),E("span",{style:{fontSize:"12px",color:e.cfg.colors.textMuted}},`${(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length} selected`)):null),!h&&u.length>0&&(()=>{var V,J,nt,it;const x=(V=t.groupBy)==null?void 0:V.field,k=Q=>{const ut=Q==null?void 0:Q[x];if(ut&&typeof ut=="object"&&ut._seconds)return ut._seconds*1e3;const Ct=Date.parse(ut);return isNaN(Ct)?0:Ct},S=Q=>{if(!Q)return"Earlier";const ut=new Date(Q),Ct=new Date,ft=qt=>`${qt.getFullYear()}-${qt.getMonth()}-${qt.getDate()}`;if(ft(ut)===ft(Ct))return"Today";const Dt=new Date(Ct);return Dt.setDate(Ct.getDate()-1),ft(ut)===ft(Dt)?"Yesterday":ut.toLocaleDateString()},P=((J=t.sort)==null?void 0:J.field)||x?[...u].sort((Q,ut)=>{var ft;const Ct=k(ut)-k(Q);return((ft=t.sort)==null?void 0:ft.direction)==="asc"?-Ct:Ct}):u,I=String(e.sceneData.recordingSearchApplied||"").trim().toLowerCase(),[L,O]=String(e.sceneData.recordingDateFilterApplied||"").split("|"),H=L?Date.parse(`${L}T00:00:00`):0,U=O?Date.parse(`${O}T23:59:59.999`):Number.POSITIVE_INFINITY,X=((nt=t.itemsFilter)!=null&&nt.field?P.filter(Q=>String(Q==null?void 0:Q[t.itemsFilter.field])===String(t.itemsFilter.eq)):P).filter(Q=>{const ut=!I||[Q.url,Q.title,Q.prompt].some(ft=>String(ft||"").toLowerCase().includes(I)),Ct=k(Q);return ut&&Ct>=H&&Ct<=U}),j={};if(x)for(const Q of X)(j[it=S(k(Q))]||(j[it]=[])).push(Q);const D=(Q,ut)=>{var Ct,ft,Dt,qt,ne,te,mt,he;if(t.renderItem){const Pe=JSON.parse(JSON.stringify(t.renderItem)),ae={...Q};if(t.labelField&&t.labelMap){const bt=String(t.labelField.split(".").reduce((Rt,Lt)=>Rt==null?void 0:Rt[Lt],Q)??"");ae.label=t.labelMap[bt]??""}const In={};if(Array.isArray(Pe.children)){for(const bt of Pe.children)if(bt.content){const Rt=bt.content.match(/^\{\{(\w+)\}\}$/);if(Rt){const Lt=Rt[1],kt=Q[Lt];Array.isArray(kt)&&(In[Lt]=kt)}}}const Oe=JSON.stringify(Pe).replace(/\{\{([\w.]+)(?:\|(date|time|datetime|timeago))?\}\}/g,(bt,Rt,Lt)=>{const kt=Rt.split(".").reduce((yt,wt)=>yt==null?void 0:yt[wt],ae);if(Array.isArray(kt))return bt;if(kt==null)return"";if(Lt){const yt=kt&&typeof kt=="object"&&"_seconds"in kt?new Date(kt._seconds*1e3):new Date(kt);if(!isNaN(yt.getTime())){if(Lt==="timeago"){const wt=Math.floor((Date.now()-yt.getTime())/6e4);if(wt<1)return"just now";if(wt<60)return`${wt}m ago`;const gt=Math.floor(wt/60);if(gt<24)return`${gt}h ago`;const Xt=Math.floor(gt/24);return Xt<7?`${Xt}d ago`:yt.toLocaleDateString()}return Lt==="date"?yt.toLocaleDateString():Lt==="time"?yt.toLocaleTimeString():yt.toLocaleString()}}return typeof kt=="string"?kt.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):kt!==void 0?JSON.stringify(kt):""}),xe=JSON.parse(Oe);if(xe.children&&(xe.children=xe.children.map(bt=>{var kt;const Rt=bt.fieldType||"text",Lt=(kt=bt.content)==null?void 0:kt.match(/^\{\{(\w+)\}\}$/);if(Lt){const yt=Lt[1],wt=In[yt];if(wt)return Rt==="dropdown"?{...bt,type:"select",content:void 0,placeholder:bt.fieldPlaceholder||`Select ${yt}...`,options:wt.map(gt=>({label:typeof gt=="object"?gt.label||gt.name||JSON.stringify(gt):String(gt),value:typeof gt=="object"?gt.value||gt.id||JSON.stringify(gt):String(gt)})),name:`${n}-${ut}-${yt}`,className:bt.className||"w-full text-sm bg-slate-700 border border-slate-500 text-white rounded-lg px-3 py-1.5"}:Rt==="multiselect"?{...bt,type:"container",content:void 0,className:bt.className||"flex flex-col gap-1 w-full",children:[...bt.fieldPlaceholder?[{type:"text",content:bt.fieldPlaceholder,className:"text-xs text-gray-400 mb-1"}]:[{type:"text",content:`Select ${yt}`,className:"text-xs text-gray-400 mb-1"}],...wt.map((gt,Xt)=>({type:"checkbox",label:typeof gt=="object"?gt.label||gt.name||JSON.stringify(gt):String(gt),name:`${n}-${ut}-${yt}-${Xt}`,className:"text-sm text-gray-200"}))]}:Rt==="image-grid"?{...bt,type:"container",content:void 0,className:"flex flex-row gap-2 w-full overflow-x-auto py-1",children:wt.slice(0,10).map((gt,Xt)=>({type:"image",src:typeof gt=="string"?gt:gt.url||gt.src||"",alt:`${yt} ${Xt+1}`,className:"w-12 h-12 rounded-lg object-cover flex-shrink-0"}))}:{...bt,type:"container",content:void 0,className:"flex flex-col gap-1 w-full",children:[{type:"text",content:`⚠ "${yt}" is an array (${wt.length} items)`,className:"text-xs font-semibold text-amber-400"},{type:"text",content:"Use ⚡ to fetch fields, then set type in sidebar",className:"text-xs text-amber-300 opacity-75"}]}}return Rt==="image"&&bt.content&&!bt.content.includes("{{")?{...bt,type:"image",src:bt.content,alt:bt.content,content:void 0,className:bt.className||"w-full h-32 rounded-lg object-cover"}:bt})),t.selectable&&e.sceneData._selectMode){const bt=String(Q.id||ut),Rt=Array.isArray(e.sceneData._selIds)&&e.sceneData._selIds.map(String).includes(bt),Lt=yt=>yt?[yt.text,yt.content,...yt.children?yt.children.flatMap(Lt):[]].filter(wt=>typeof wt=="string"&&wt.trim()&&!wt.includes("{{")):[],kt=xe.text||xe.label||Lt(xe).slice(0,2).join(" — ")||String(Q.id||ut);return E("button",{key:`${n}-item-${ut}`,className:(Ct=t.selectionStyle)==null?void 0:Ct.className,type:"button",onClick:()=>{e.setSceneData(yt=>({...yt,_selIds:(()=>{const wt=Array.isArray(yt._selIds)?yt._selIds.map(String):[];return wt.includes(bt)?wt.filter(gt=>gt!==bt):[...wt,bt]})()}))},style:{width:"100%",textAlign:"left",padding:"1rem 2rem",border:`1px solid ${Rt?((ft=t.selectionStyle)==null?void 0:ft.selectedBorderColor)||e.cfg.colors.accent||"#fff":((Dt=t.selectionStyle)==null?void 0:Dt.borderColor)||e.cfg.colors.border}`,borderRadius:((qt=t.selectionStyle)==null?void 0:qt.borderRadius)||e.cfg.components.inputRadius||"8px",marginBottom:"0.5rem",backgroundColor:Rt?((ne=t.selectionStyle)==null?void 0:ne.selectedBackgroundColor)||e.cfg.colors.surface:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontFamily:"inherit",fontSize:"14px",fontWeight:Rt?600:400,transition:"all 0.15s ease",outline:"none"},onMouseEnter:yt=>{var gt,Xt;const wt=yt.currentTarget.firstElementChild;!Rt&&wt&&(wt.style.borderColor=((gt=t.selectionStyle)==null?void 0:gt.selectedBorderColor)||e.cfg.colors.accent||"#fff",wt.style.backgroundColor=((Xt=t.selectionStyle)==null?void 0:Xt.selectedBackgroundColor)||e.cfg.colors.surface,yt.currentTarget.style.borderColor=e.cfg.colors.textMuted)},onMouseLeave:yt=>{var gt,Xt,Ue;const wt=yt.currentTarget.firstElementChild;!Rt&&wt&&(wt.style.borderColor=((gt=t.selectionStyle)==null?void 0:gt.borderColor)||e.cfg.colors.border,wt.style.backgroundColor="transparent"),yt.currentTarget.style.borderColor=Rt?((Xt=t.selectionStyle)==null?void 0:Xt.selectedBorderColor)||e.cfg.colors.accent||"#fff":((Ue=t.selectionStyle)==null?void 0:Ue.borderColor)||e.cfg.colors.border}},E("span",{"aria-hidden":!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",marginRight:"10px",border:`1px solid ${Rt?((te=t.selectionStyle)==null?void 0:te.selectedBorderColor)||e.cfg.colors.accent||"#fff":((mt=t.selectionStyle)==null?void 0:mt.borderColor)||e.cfg.colors.border}`,borderRadius:"5px",backgroundColor:Rt?((he=t.selectionStyle)==null?void 0:he.selectedBorderColor)||e.cfg.colors.accent||"#fff":"transparent",color:Rt?e.cfg.colors.background:"transparent",transition:"all 0.15s ease"}},Rt?e.renderIcon("check",12):null),kt)}return E("div",{key:`${n}-row-${ut}`,style:{display:"contents"},onClickCapture:()=>{e.rowContextRef&&(e.rowContextRef.current=Q)}},e.renderComponent(xe,ut,`${n}-item`))}return null};return x?Object.entries(j).map(([Q,ut],Ct)=>E("div",{key:`${n}-group-${Ct}`,style:{display:"flex",flexDirection:"column",gap:"6px"}},E("div",{key:`${n}-group-hdr-${Ct}`,style:{fontSize:"11px",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",color:e.cfg.colors.textMuted,padding:"10px 4px 2px"}},Q),ut.map(D))):X.map(D)})(),r&&(s==null?void 0:s.hasMore)&&E("div",{"data-bf-scroll-load":n,style:{height:"48px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",...h&&((s==null?void 0:s.page)??0)>0?{}:{pointerEvents:"none",opacity:.55}}},h&&((s==null?void 0:s.page)??0)>0?E("div",{style:{width:"18px",height:"18px",border:"2px solid rgba(128,128,128,0.25)",borderTopColor:e.cfg.colors.primary,borderRadius:"50%",animation:"bf-spin 0.7s linear infinite"}}):E("div",{style:{width:"18px",height:"2px",borderRadius:"2px",background:e.cfg.colors.textMuted,opacity:.4}})),i&&m.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page-1,s.limit),disabled:s.page===0||h,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),E("span",{className:"text-xs text-gray-500"},`${s.page+1} / ${o}`),m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page+1,s.limit),disabled:!s.hasMore||h,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function mv({api:e,c:t,componentKey:n}){var H,U,q,X;const s=(H=e.paginationState)==null?void 0:H[n],i=t.pagination!==!1&&s&&s.total>s.limit,r=s?Math.ceil(s.total/s.limit):0,o=t.className||"w-full overflow-x-auto rounded-xl bg-gray-800/50 border border-gray-700/50",l=((U=e.parseClassNameResponsive)==null?void 0:U.call(e,o,n))??e.parseClassName(o);t.rawStyle&&Object.assign(l,t.rawStyle);const c=(q=e.loading)==null?void 0:q[n],h=(X=e.listData)==null?void 0:X[n],a=Array.isArray(h)?h:[],u=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{},f=!!t.sortable,p=t.sortMode==="client"?"client":"server",[g,d]=m.useState(null),[w,C]=m.useState({}),x=m.useMemo(()=>{if(!g||p!=="client")return a;const j=g.dir==="asc"?1:-1;return[...a].sort((D,V)=>{const J=D[g.key],nt=V[g.key];return J===nt?0:J==null?1:nt==null?-1:String(J).localeCompare(String(nt),void 0,{numeric:!0})*j})},[a,g,p]),k=j=>{if(!f&&!j.sortable)return;const D=j.field||j.key;let V=null;!g||g.key!==D?V={key:D,dir:"asc"}:g.dir==="asc"&&(V={key:D,dir:"desc"}),d(V),p==="server"&&V&&e.fetchListData(t.dataSource,n,0,(s==null?void 0:s.limit)||t.pageSize||10,V.key,V.dir)},S=(j,D)=>j.replace(/\{\{([\w.]+)(?:\s*\|\|\s*([^}]+))?\}\}/g,(V,J,nt)=>{const it=J.split(".").reduce((Q,ut)=>Q==null?void 0:Q[ut],D);return it==null||it===""?nt??"":String(it)}),T=async(j,D)=>{var nt;const V=w[j.id??""]||{},J=D.filter(it=>it.editable&&V[it.field||it.key]!==void 0);for(const it of J){const Q=it.field||it.key,ut=it.onCellChange||t.onSave;if(!ut)continue;const Ct=ut.replace(/\{\{field\}\}/g,JSON.stringify(V[Q]));if(Ct.startsWith("sdk:"))await e.handleButtonClick(S(Ct,j),{});else{const ft=S(Ct,j);await fetch(ft,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[Q]:V[Q]})})}}J.length&&((nt=e.showToast)==null||nt.call(e,(J.length===1,"Saved"),"success"),C(it=>{const Q={...it};return delete Q[j.id??""],Q}),e.fetchListData(t.dataSource,n,(s==null?void 0:s.page)||0,(s==null?void 0:s.limit)||t.pageSize||10))},P=(j,D,V)=>{const J=D.field||D.key,nt=j.id??"";C(it=>({...it,[nt]:{...it[nt]||{},[J]:V}}))},I=(j,D)=>{const V=j.field||j.key,J=D.id??"",nt=w[J]||{},it=nt[V]!==void 0?nt[V]:D[V],Q=j.fieldType||"text",ut={style:{width:"100%",background:"transparent",color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",padding:"2px 6px",fontSize:"13px",fontFamily:"inherit"}},Ct=()=>{j.onCellChange&&nt[j.key]!==void 0&&T(D,[j])};if(Q==="select"||Q==="dropdown")return E("select",{...ut,value:String(it??""),onChange:ft=>{P(D,j,ft.target.value),j.onCellChange&&T(D,[j])},children:(Array.isArray(j.fieldOptions)?j.fieldOptions:[]).map((ft,Dt)=>E("option",{key:Dt,value:ft.value,children:ft.label??ft.value}))});if(Q==="multiselect"){const ft=Array.isArray(it)?it:[];return E("div",{style:{display:"flex",flexDirection:"column",gap:2}},(Array.isArray(j.fieldOptions)?j.fieldOptions:[]).map((Dt,qt)=>{const ne=ft.includes(Dt.value);return E("label",{key:qt,style:{display:"flex",alignItems:"center",gap:4,fontSize:12}},E("input",{type:"checkbox",checked:ne,onChange:te=>{const mt=te.target.checked?[...ft,Dt.value]:ft.filter(he=>he!==Dt.value);P(D,j,mt),j.onCellChange&&T(D,[j])}}),E("span",{children:Dt.label??Dt.value}))}))}return Q==="image"?E("div",{style:{display:"flex",alignItems:"center",gap:6}},it?E("img",{src:String(it),alt:j.label,style:{width:32,height:32,borderRadius:4,objectFit:"cover"}}):null,E("input",{...ut,value:String(it??""),placeholder:j.fieldPlaceholder||"Image URL",onChange:ft=>P(D,j,ft.target.value),onBlur:Ct})):E("input",{...ut,type:Q==="number"?"number":"text",value:String(it??""),placeholder:j.fieldPlaceholder||"",onChange:ft=>P(D,j,Q==="number"?Number(ft.target.value):ft.target.value),onBlur:Ct})},L=j=>{const D=w[j.id??""];return!!D&&Object.keys(D).some(V=>{var J;return(J=t.columns)==null?void 0:J.some(nt=>nt.editable&&(nt.field||nt.key)===V)})},O=!!t.onSave;return m.createElement("div",{key:n,className:o,style:l,"data-component-key":n,...u},c&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):m.createElement("div",{className:"flex justify-center py-4"},E("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),m.createElement("table",{className:"w-full"},Array.isArray(t.columns)&&m.createElement("thead",{className:"bg-gray-900/50"},m.createElement("tr",{},t.columns.map(j=>m.createElement("th",{key:j.key,className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},(f||j.sortable)&&j.sortable!==!1?(()=>{const D=g&&g.key===j.key?g:null;return E("button",{type:"button",onClick:()=>k(j),style:{background:"none",border:"none",color:"inherit",fontFamily:"inherit",fontSize:"inherit",cursor:"pointer",padding:0},children:`${j.label||j.key}${D?D.dir==="asc"?" ↑":" ↓":" ⇅"}`})})():j.label||j.key)),O&&m.createElement("th",{key:"__save",className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},""))),m.createElement("tbody",{className:"divide-y divide-gray-700/50"},x.map((j,D)=>{var V;return m.createElement("tr",{key:j.id??D,className:"hover:bg-gray-700/30 transition-colors"},(V=t.columns)==null?void 0:V.map(J=>m.createElement("td",{key:J.key,className:"px-4 py-3 text-sm text-white"},J.editable?I(J,j):J.template?S(J.template,j):(()=>{const it=(J.field||J.key).split(".").reduce((Q,ut)=>Q==null?void 0:Q[ut],j);return it==null||it===""?"":String(it)})())),O&&m.createElement("td",{key:"__save-cell",className:"px-4 py-3 text-sm"},E("button",{type:"button",disabled:!L(j)||c,onClick:()=>T(j,t.columns||[]),className:"px-3 py-1 rounded text-xs font-semibold border transition-all disabled:opacity-40 disabled:cursor-not-allowed",style:{background:L(j)?e.cfg.colors.primary:"transparent",color:L(j)?"#ffffff":e.cfg.colors.textSecondary,borderColor:e.cfg.colors.border},children:"Save"})))}))),i&&m.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page-1,s.limit),disabled:s.page===0||c,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),E("span",{className:"text-xs text-gray-500"},`${s.page+1} / ${r}`),m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page+1,s.limit),disabled:!s.hasMore||c,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function pv(e,t,n){return m.createElement(mv,{api:e,c:t,componentKey:n})}function Nt(e){var t=e.width,n=e.height;if(t<0)throw new Error("Negative width is not allowed for Size");if(n<0)throw new Error("Negative height is not allowed for Size");return{width:t,height:n}}function Zn(e,t){return e.width===t.width&&e.height===t.height}var gv=function(){function e(t){var n=this;this._resolutionListener=function(){return n._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return e.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(e.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(t){var n=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){n._observers=n._observers.filter(function(i){return i!==s})}}},e.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},e.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},e.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},e.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(n){return n.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},e}();function yv(e){return new gv(e)}var bv=function(){function e(t,n,s){var i;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=Nt({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=n??function(r){return r},this._allowResizeObserver=(i=s==null?void 0:s.allowResizeObserver)!==null&&i!==void 0?i:!0,this._chooseAndInitObserver()}return e.prototype.dispose=function(){var t,n;if(this._canvasElement===null)throw new Error("Object is disposed");(t=this._canvasElementResizeObserver)===null||t===void 0||t.disconnect(),this._canvasElementResizeObserver=null,(n=this._devicePixelRatioObservable)===null||n===void 0||n.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(e.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bitmapSize",{get:function(){return Nt({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),e.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=Nt(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},e.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(n){return n!==t})},Object.defineProperty(e.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),e.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(n){return n!==t})},e.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},e.prototype._resizeBitmap=function(t){var n=this.bitmapSize;Zn(n,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(n,t))},e.prototype._emitBitmapSizeChanged=function(t,n){var s=this;this._bitmapSizeChangedListeners.forEach(function(i){return i.call(s,t,n)})},e.prototype._suggestNewBitmapSize=function(t){var n=this._suggestedBitmapSize,s=Nt(this._transformBitmapSize(t,this._canvasElementClientSize)),i=Zn(this.bitmapSize,s)?null:s;n===null&&i===null||n!==null&&i!==null&&Zn(n,i)||(this._suggestedBitmapSize=i,this._emitSuggestedBitmapSizeChanged(n,i))},e.prototype._emitSuggestedBitmapSizeChanged=function(t,n){var s=this;this._suggestedBitmapSizeChangedListeners.forEach(function(i){return i.call(s,t,n)})},e.prototype._chooseAndInitObserver=function(){var t=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}xv().then(function(n){return n?t._initResizeObserver():t._initDevicePixelRatioObservable()})},e.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var n=Ih(this._canvasElement);if(n===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=yv(n),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},e.prototype._invalidateBitmapSize=function(){var t,n;if(this._canvasElement!==null){var s=Ih(this._canvasElement);if(s!==null){var i=(n=(t=this._devicePixelRatioObservable)===null||t===void 0?void 0:t.value)!==null&&n!==void 0?n:s.devicePixelRatio,r=this._canvasElement.getClientRects(),o=r[0]!==void 0?wv(r[0],i):Nt({width:this._canvasElementClientSize.width*i,height:this._canvasElementClientSize.height*i});this._suggestNewBitmapSize(o)}}},e.prototype._initResizeObserver=function(){var t=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(n){var s=n.find(function(o){return o.target===t._canvasElement});if(!(!s||!s.devicePixelContentBoxSize||!s.devicePixelContentBoxSize[0])){var i=s.devicePixelContentBoxSize[0],r=Nt({width:i.inlineSize,height:i.blockSize});t._suggestNewBitmapSize(r)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},e}();function vv(e,t){return new bv(e,t.transform,t.options)}function Ih(e){return e.ownerDocument.defaultView}function xv(){return new Promise(function(e){var t=new ResizeObserver(function(n){e(n.every(function(s){return"devicePixelContentBoxSize"in s})),t.disconnect()});t.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function wv(e,t){return Nt({width:Math.round(e.left*t+e.width*t)-Math.round(e.left*t),height:Math.round(e.top*t+e.height*t)-Math.round(e.top*t)})}var Sv=function(){function e(t,n,s){if(n.width===0||n.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=n,s.width===0||s.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return e.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},e.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(e.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),e}();function ts(e,t){var n=e.canvasElementClientSize;if(n.width===0||n.height===0)return null;var s=e.bitmapSize;if(s.width===0||s.height===0)return null;var i=e.canvasElement.getContext("2d",t);return i===null?null:new Sv(i,n,s)}/*!
|
|
11
11
|
* @license
|
|
12
12
|
* TradingView Lightweight Charts™ v5.2.1
|
|
13
13
|
* Copyright (c) 2026 TradingView, Inc.
|
|
14
14
|
* Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
*/const zf={title:"",visible:!0,hitTestTolerance:3,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var Dh,Lh;function Pn(e,t){const n=function(s,i){switch(s){case 0:default:return[];case 1:return[i,i];case 2:return[2*i,2*i];case 3:return[6*i,6*i];case 4:return[i,4*i]}}(t,e.lineWidth);return e.setLineDash(n),n}function Ff(e,t,n,s){e.beginPath();const i=e.lineWidth%2?.5:0;e.moveTo(n,t+i),e.lineTo(s,t+i),e.stroke()}function pe(e,t){if(!e)throw new Error("Assertion failed"+(t?": "+t:""))}function Re(e){if(e===void 0)throw new Error("Value is undefined");return e}function K(e){if(e===null)throw new Error("Value is null");return e}function Mn(e){return K(Re(e))}(function(e){e[e.Simple=0]="Simple",e[e.WithSteps=1]="WithSteps",e[e.Curved=2]="Curved"})(Dh||(Dh={})),function(e){e[e.Solid=0]="Solid",e[e.Dotted=1]="Dotted",e[e.Dashed=2]="Dashed",e[e.LargeDashed=3]="LargeDashed",e[e.SparseDotted=4]="SparseDotted"}(Lh||(Lh={}));class Zt{constructor(){this.t=[]}i(t,n,s){const i={h:t,l:n,o:s===!0};this.t.push(i)}_(t){const n=this.t.findIndex(s=>t===s.h);n>-1&&this.t.splice(n,1)}u(t){this.t=this.t.filter(n=>n.l!==t)}p(t,n,s){const i=[...this.t];this.t=this.t.filter(r=>!r.o),i.forEach(r=>r.h(t,n,s))}v(){return this.t.length>0}m(){this.t=[]}}function $e(e,...t){for(const n of t)for(const s in n)n[s]!==void 0&&Object.prototype.hasOwnProperty.call(n,s)&&!["__proto__","constructor","prototype"].includes(s)&&(typeof n[s]!="object"||e[s]===void 0||Array.isArray(n[s])?e[s]=n[s]:$e(e[s],n[s]));return e}function Ws(e){return typeof e=="number"&&isFinite(e)}function $i(e){return typeof e=="number"&&e%1==0}function Bi(e){return typeof e=="string"}function or(e){return typeof e=="boolean"}function an(e){const t=e;if(!t||typeof t!="object")return t;let n,s,i;for(s in n=Array.isArray(t)?[]:{},t)t.hasOwnProperty(s)&&(i=t[s],n[s]=i&&typeof i=="object"?an(i):i);return n}function zh(e){return e!==null}function Ni(e){return e===null?void 0:e}const Bf="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function Ir(e,t,n){return t===void 0&&(t=Bf),`${n=n!==void 0?`${n} `:""}${e}px ${t}`}class xv{constructor(t){this.M={S:1,C:5,P:NaN,k:"",T:"",R:"",D:"",I:0,V:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,n=this.F(),s=this.W();return t.P===n&&t.T===s||(t.P=n,t.T=s,t.k=Ir(n,s),t.A=2.5/12*n,t.I=t.A,t.V=n/12*t.C,t.B=n/12*t.C,t.L=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function Po(e){return e<0?0:e>255?255:Math.round(e)||0}function Fh(e){return .199*e[0]+.687*e[1]+.114*e[2]}class wv{constructor(t,n){this.j=new Map,this.q=t,n&&(this.j=n)}Y(t,n){if(t==="transparent")return t;const s=this.K(t),i=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${n*i})`}G(t){const n=this.K(t);return{Z:`rgb(${n[0]}, ${n[1]}, ${n[2]})`,X:Fh(n)>160?"black":"white"}}J(t){return Fh(this.K(t))}tt(t,n,s){const[i,r,o,l]=this.K(t),[c,h,a,u]=this.K(n),f=[Po(i+s*(c-i)),Po(r+s*(h-r)),Po(o+s*(a-o)),(p=l+s*(u-l),p<=0||p>1?Math.min(Math.max(p,0),1):Math.round(1e4*p)/1e4)];var p;return`rgba(${f[0]}, ${f[1]}, ${f[2]}, ${f[3]})`}K(t){const n=this.j.get(t);if(n)return n;const s=function(o){const l=document.createElement("div");l.style.display="none",document.body.appendChild(l),l.style.color=o;const c=window.getComputedStyle(l).color;return document.body.removeChild(l),c}(t),i=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!i){if(this.q.length)for(const o of this.q){const l=o(t);if(l)return this.j.set(t,l),l}throw new Error(`Failed to parse color: ${t}`)}const r=[parseInt(i[1],10),parseInt(i[2],10),parseInt(i[3],10),i[4]?parseFloat(i[4]):1];return this.j.set(t,r),r}}class Sv{constructor(){this.it=[]}nt(t){this.it=t}st(t,n,s){this.it.forEach(i=>{i.st(t,n,s)})}}class $n{st(t,n,s){t.useBitmapCoordinateSpace(i=>this.et(i,n,s))}}class Cv extends $n{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:s}){if(this.rt===null||this.rt.lt===null)return;const i=this.rt.lt,r=this.rt,o=Math.max(1,Math.floor(n))%2/2,l=c=>{t.beginPath();for(let h=i.to-1;h>=i.from;--h){const a=r.ot[h],u=Math.round(a._t*n)+o,f=a.ut*s,p=c*s+o;t.moveTo(u,f),t.arc(u,f,p,0,2*Math.PI)}t.fill()};r.ct>0&&(t.fillStyle=r.dt,l(r.ft+r.ct)),t.fillStyle=r.vt,l(r.ft)}}function kv(){return{ot:[{_t:0,ut:0,wt:0,Mt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const Mv={from:0,to:1};class Ev{constructor(t,n,s){this.gt=new Sv,this.bt=[],this.St=[],this.xt=!0,this.O=t,this.Ct=n,this.yt=s,this.gt.nt(this.bt)}Pt(t){this.kt(),this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.gt}kt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.St=t.map(kv),this.bt=this.St.map(n=>{const s=new Cv;return s.ht(n),s}),this.gt.nt(this.bt))}Rt(){const t=this.Ct.N().mode===2||!this.Ct.It(),n=this.yt.Vt(),s=this.Ct.Bt(),i=this.O.Et();this.kt(),n.forEach((r,o)=>{const l=this.St[o],c=r.At(s),h=r.Lt();!t&&c!==null&&r.It()&&h!==null?(l.vt=c.zt,l.ft=c.ft,l.ct=c.Ot,l.ot[0].Mt=c.Mt,l.ot[0].ut=r.Ft().Nt(c.Mt,h.Wt),l.dt=c.Ht??this.O.Ut(l.ot[0].ut/r.Ft().$t()),l.ot[0].wt=s,l.ot[0]._t=i.jt(s),l.lt=Mv):l.lt=null})}}class Tv extends $n{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null)return;const r=this.qt.Yt.It,o=this.qt.Kt.It;if(!r&&!o)return;const l=Math.round(this.qt._t*s),c=Math.round(this.qt.ut*i);t.lineCap="butt",r&&l>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*s),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,Pn(t,this.qt.Yt.Gt),function(h,a,u,f){h.beginPath();const p=h.lineWidth%2?.5:0;h.moveTo(a+p,u),h.lineTo(a+p,f),h.stroke()}(t,l,0,n.height)),o&&c>=0&&(t.lineWidth=Math.floor(this.qt.Kt.ct*i),t.strokeStyle=this.qt.Kt.R,t.fillStyle=this.qt.Kt.R,Pn(t,this.qt.Kt.Gt),Ff(t,c,0,n.width))}}class Av{constructor(t,n){this.xt=!0,this.Zt={Yt:{ct:1,Gt:0,R:"",It:!1},Kt:{ct:1,Gt:0,R:"",It:!1},_t:0,ut:0},this.Xt=new Tv(this.Zt),this.Jt=t,this.yt=n}Pt(){this.xt=!0}Tt(t){return this.xt&&(this.Rt(),this.xt=!1),this.Xt}Rt(){const t=this.Jt.It(),n=this.yt.Qt().N().crosshair,s=this.Zt;if(n.mode===2)return s.Kt.It=!1,void(s.Yt.It=!1);s.Kt.It=t&&this.Jt.ti(this.yt),s.Yt.It=t&&this.Jt.ii(),s.Kt.ct=n.horzLine.width,s.Kt.Gt=n.horzLine.style,s.Kt.R=n.horzLine.color,s.Yt.ct=n.vertLine.width,s.Yt.Gt=n.vertLine.style,s.Yt.R=n.vertLine.color,s._t=this.Jt.ni(),s.ut=this.Jt.si()}}function Rv(e,t,n,s,i,r){e.fillRect(t+r,n,s-2*r,r),e.fillRect(t+r,n+i-r,s-2*r,r),e.fillRect(t,n,r,i),e.fillRect(t+s-r,n,r,i)}function Yr(e,t,n,s,i,r){e.save(),e.globalCompositeOperation="copy",e.fillStyle=r,e.fillRect(t,n,s,i),e.restore()}function Bh(e,t,n,s,i,r){e.beginPath(),e.roundRect?e.roundRect(t,n,s,i,r):(e.lineTo(t+s-r[1],n),r[1]!==0&&e.arcTo(t+s,n,t+s,n+r[1],r[1]),e.lineTo(t+s,n+i-r[2]),r[2]!==0&&e.arcTo(t+s,n+i,t+s-r[2],n+i,r[2]),e.lineTo(t+r[3],n+i),r[3]!==0&&e.arcTo(t,n+i,t,n+i-r[3],r[3]),e.lineTo(t,n+r[0]),r[0]!==0&&e.arcTo(t,n,t+r[0],n,r[0]))}function Wh(e,t,n,s,i,r,o=0,l=[0,0,0,0],c=""){if(e.save(),!o||!c||c===r)return Bh(e,t,n,s,i,l),e.fillStyle=r,e.fill(),void e.restore();const h=o/2;var a;Bh(e,t+h,n+h,s-o,i-o,(a=-h,l.map(u=>u===0?u:u+a))),r!=="transparent"&&(e.fillStyle=r,e.fill()),c!=="transparent"&&(e.lineWidth=o,e.strokeStyle=c,e.closePath(),e.stroke()),e.restore()}function Wf(e,t,n,s,i,r,o){e.save(),e.globalCompositeOperation="copy";const l=e.createLinearGradient(0,0,0,i);l.addColorStop(0,r),l.addColorStop(1,o),e.fillStyle=l,e.fillRect(t,n,s,i),e.restore()}class Vh{constructor(t,n){this.ht(t,n)}ht(t,n){this.qt=t,this.ei=n}$t(t,n){return this.qt.It?t.P+t.A+t.I:0}st(t,n,s,i){if(!this.qt.It||this.qt.ri.length===0)return;const r=this.qt.R,o=this.ei.Z,l=t.useBitmapCoordinateSpace(c=>{const h=c.context;h.font=n.k;const a=this.hi(c,n,s,i),u=a.ai;return a.li?Wh(h,u.oi,u._i,u.ui,u.ci,o,u.di,[u.ft,0,0,u.ft],o):Wh(h,u.fi,u._i,u.ui,u.ci,o,u.di,[0,u.ft,u.ft,0],o),this.qt.pi&&(h.fillStyle=r,h.fillRect(u.fi,u.mi,u.wi-u.fi,u.Mi)),this.qt.gi&&(h.fillStyle=n.D,h.fillRect(a.li?u.bi-u.di:0,u._i,u.di,u.Si-u._i)),a});t.useMediaCoordinateSpace(({context:c})=>{const h=l.xi;c.font=n.k,c.textAlign=l.li?"right":"left",c.textBaseline="middle",c.fillStyle=r,c.fillText(this.qt.ri,h.Ci,(h._i+h.Si)/2+h.yi)})}hi(t,n,s,i){const{context:r,bitmapSize:o,mediaSize:l,horizontalPixelRatio:c,verticalPixelRatio:h}=t,a=this.qt.pi||!this.qt.Pi?n.C:0,u=this.qt.ki?n.S:0,f=n.A+this.ei.Ti,p=n.I+this.ei.Ri,g=n.V,d=n.B,w=this.qt.ri,C=n.P,x=s.Di(r,w),k=Math.ceil(s.Ii(r,w)),S=C+f+p,T=n.S+g+d+k+a,P=Math.max(1,Math.floor(h));let I=Math.round(S*h);I%2!=P%2&&(I+=1);const L=u>0?Math.max(1,Math.floor(u*c)):0,O=Math.round(T*c),H=Math.round(a*c),U=this.ei.Vi??this.ei.Bi??this.ei.Ei,q=Math.round(U*h)-Math.floor(.5*h),X=Math.floor(q+P/2-I/2),V=X+I,D=i==="right",j=D?l.width-u:u,J=D?o.width-L:L;let nt,it,Q;return D?(nt=J-O,it=J-H,Q=j-a-g-u):(nt=J+O,it=J+H,Q=j+a+g),{li:D,ai:{_i:X,mi:q,Si:V,ui:O,ci:I,ft:2*c,di:L,oi:nt,fi:J,wi:it,Mi:P,bi:o.width},xi:{_i:X/h,Si:V/h,Ci:Q,yi:x}}}}class Xr{constructor(t){this.Ai={Ei:0,Z:"#000",Ri:0,Ti:0},this.Li={ri:"",It:!1,pi:!0,Pi:!1,Ht:"",R:"#FFF",gi:!1,ki:!1},this.zi={ri:"",It:!1,pi:!1,Pi:!0,Ht:"",R:"#FFF",gi:!0,ki:!0},this.xt=!0,this.Oi=new(t||Vh)(this.Li,this.Ai),this.Ni=new(t||Vh)(this.zi,this.Ai)}ri(){return this.Fi(),this.Li.ri}Ei(){return this.Fi(),this.Ai.Ei}Pt(){this.xt=!0}$t(t,n=!1){return Math.max(this.Oi.$t(t,n),this.Ni.$t(t,n))}Wi(){return this.Ai.Vi??null}Hi(){return this.Ai.Vi??this.Ai.Bi??this.Ei()}Ui(t){this.Ai.Bi=t??void 0}$i(){return this.Fi(),this.Li.It||this.zi.It}ji(){return this.Fi(),this.Li.It}Tt(t){return this.Fi(),this.Li.pi=this.Li.pi&&t.N().ticksVisible,this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Ni}Fi(){this.xt&&(this.Li.pi=!0,this.zi.pi=!1,this.Yi(this.Li,this.zi,this.Ai))}}class Pv extends Xr{constructor(t,n,s){super(),this.Jt=t,this.Ki=n,this.Gi=s}Yi(t,n,s){if(t.It=!1,this.Jt.N().mode===2)return;const i=this.Jt.N().horzLine;if(!i.labelVisible)return;const r=this.Ki.Lt();if(!this.Jt.It()||this.Ki.Zi()||r===null)return;const o=this.Ki.Xi().G(i.labelBackgroundColor);s.Z=o.Z,t.R=o.X;const l=2/12*this.Ki.P();s.Ti=l,s.Ri=l;const c=this.Gi(this.Ki);s.Ei=c.Ei,t.ri=this.Ki.Ji(c.Mt,r),t.It=!0}}const _v=/[1-9]/g;class Vf{constructor(){this.qt=null}ht(t){this.qt=t}st(t,n){if(this.qt===null||this.qt.It===!1||this.qt.ri.length===0)return;const s=t.useMediaCoordinateSpace(({context:f})=>(f.font=n.k,Math.round(n.Qi.Ii(f,K(this.qt).ri,_v))));if(s<=0)return;const i=n.tn,r=s+2*i,o=r/2,l=this.qt.nn;let c=this.qt.Ei,h=Math.floor(c-o)+.5;h<0?(c+=Math.abs(0-h),h=Math.floor(c-o)+.5):h+r>l&&(c-=Math.abs(l-(h+r)),h=Math.floor(c-o)+.5);const a=h+r,u=Math.ceil(0+n.S+n.C+n.A+n.P+n.I);t.useBitmapCoordinateSpace(({context:f,horizontalPixelRatio:p,verticalPixelRatio:g})=>{const d=K(this.qt);f.fillStyle=d.Z;const w=Math.round(h*p),C=Math.round(0*g),x=Math.round(a*p),k=Math.round(u*g),S=Math.round(2*p);if(f.beginPath(),f.moveTo(w,C),f.lineTo(w,k-S),f.arcTo(w,k,w+S,k,S),f.lineTo(x-S,k),f.arcTo(x,k,x,k-S,S),f.lineTo(x,C),f.fill(),d.pi){const T=Math.round(d.Ei*p),P=C,I=Math.round((P+n.C)*g);f.fillStyle=d.R;const L=Math.max(1,Math.floor(p)),O=Math.floor(.5*p);f.fillRect(T-O,P,L,I-P)}}),t.useMediaCoordinateSpace(({context:f})=>{const p=K(this.qt),g=0+n.S+n.C+n.A+n.P/2;f.font=n.k,f.textAlign="left",f.textBaseline="middle",f.fillStyle=p.R;const d=n.Qi.Di(f,"Apr0");f.translate(h+i,g+d),f.fillText(p.ri,0,0)})}}class $v{constructor(t,n,s){this.xt=!0,this.Xt=new Vf,this.Zt={It:!1,Z:"#4c525e",R:"white",ri:"",nn:0,Ei:NaN,pi:!0},this.Ct=t,this.sn=n,this.Gi=s}Pt(){this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Xt.ht(this.Zt),this.Xt}Rt(){const t=this.Zt;if(t.It=!1,this.Ct.N().mode===2)return;const n=this.Ct.N().vertLine;if(!n.labelVisible)return;const s=this.sn.Et();if(s.Zi())return;t.nn=s.nn();const i=this.Gi();if(i===null)return;t.Ei=i.Ei;const r=s.en(this.Ct.Bt());t.ri=s.rn(K(r)),t.It=!0;const o=this.sn.Xi().G(n.labelBackgroundColor);t.Z=o.Z,t.R=o.X,t.pi=s.N().ticksVisible}}class jf{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(t){this.an=t}Ft(){return this.hn}un(t){this.hn=t}cn(t){return[]}dn(){return[]}It(){return!0}}var jh;(function(e){e[e.Normal=0]="Normal",e[e.Magnet=1]="Magnet",e[e.Hidden=2]="Hidden",e[e.MagnetOHLC=3]="MagnetOHLC"})(jh||(jh={}));class Nv extends jf{constructor(t,n){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.Mn=new WeakMap,this.gn=new WeakMap,this.bn=NaN,this.Sn=NaN,this.xn=NaN,this.Cn=NaN,this.sn=t,this.yn=n,this.Pn=((i,r)=>o=>{const l=r(),c=i();if(o===K(this.yt).kn())return{Mt:c,Ei:l};{const h=K(o.Lt());return{Mt:o.Tn(l,h),Ei:l}}})(()=>this.fn,()=>this.Sn);const s=((i,r)=>()=>{const o=this.sn.Et().Rn(i()),l=r();return o&&Number.isFinite(l)?{wt:o,Ei:l}:null})(()=>this.pn,()=>this.ni());this.Dn=new $v(this,t,s)}N(){return this.yn}In(t,n){this.xn=t,this.Cn=n}Vn(){this.xn=NaN,this.Cn=NaN}Bn(){return this.xn}En(){return this.Cn}An(t,n,s){this.wn||(this.wn=!0),this.vn=!0,this.Ln(t,n,s)}Bt(){return this.pn}ni(){return this.bn}si(){return this.Sn}It(){return this.vn}zn(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.Sn=NaN,this.yt=null,this.Vn(),this.Nn()}Fn(t){if(!this.yn.doNotSnapToHiddenSeriesIndices)return t;const n=this.sn,s=n.Et();let i=null,r=null;for(const h of n.Wn()){const a=h.Un().Hn(t,-1);if(a){if(a.$n===t)return t;(i===null||a.$n>i)&&(i=a.$n)}const u=h.Un().Hn(t,1);if(u){if(u.$n===t)return t;(r===null||u.$n<r)&&(r=u.$n)}}const o=[i,r].filter(zh);if(o.length===0)return t;const l=s.jt(t),c=o.map(h=>Math.abs(l-s.jt(h)));return o[c.indexOf(Math.min(...c))]}jn(t){let n=this.Mn.get(t);n||(n=new Av(this,t),this.Mn.set(t,n));let s=this.gn.get(t);return s||(s=new Ev(this.sn,this,t),this.gn.set(t,s)),[n,s]}ti(t){return t===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(t,n){this.vn&&this.yt===t||this.mn.clear();const s=[];return this.yt===t&&s.push(this.Yn(this.mn,n,this.Pn)),s}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Gn().forEach(t=>{var n,s;(n=this.Mn.get(t))==null||n.Pt(),(s=this.gn.get(t))==null||s.Pt()}),this.mn.forEach(t=>t.Pt()),this.Dn.Pt()}Zn(t){return t&&!t.kn().Zi()?t.kn():null}Ln(t,n,s){this.Xn(t,n,s)&&this.Nn()}Xn(t,n,s){const i=this.bn,r=this.Sn,o=this.fn,l=this.pn,c=this.yt,h=this.Zn(s);this.pn=t,this.bn=isNaN(t)?NaN:this.sn.Et().jt(t),this.yt=s;const a=h!==null?h.Lt():null;return h!==null&&a!==null?(this.fn=n,this.Sn=h.Nt(n,a)):(this.fn=NaN,this.Sn=NaN),i!==this.bn||r!==this.Sn||l!==this.pn||o!==this.fn||c!==this.yt}On(){const t=this.sn.Jn().map(s=>s.Un().Qn()).filter(zh),n=t.length===0?null:Math.max(...t);this.pn=n!==null?n:NaN}Yn(t,n,s){let i=t.get(n);return i===void 0&&(i=new Pv(this,n,s),t.set(n,i)),i}}function Qr(e){return e==="left"||e==="right"}class fe{constructor(t){this.ts=new Map,this.ns=[],this.ss=t}es(t,n){const s=function(i,r){return i===void 0?r:{rs:Math.max(i.rs,r.rs),hs:i.hs||r.hs}}(this.ts.get(t),n);this.ts.set(t,s)}ls(){return this.ss}_s(t){const n=this.ts.get(t);return n===void 0?{rs:this.ss}:{rs:Math.max(this.ss,n.rs),hs:n.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(t){this.cs(),this.ns=[{ds:1,Wt:t}]}ps(t){this.vs(),this.ns.push({ds:5,Wt:t})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}Ms(t){this.cs(),this.ns.push({ds:2,Wt:t})}gs(t){this.cs(),this.ns.push({ds:3,Wt:t})}bs(){return this.ns}Ss(t){for(const n of t.ns)this.xs(n);this.ss=Math.max(this.ss,t.ss),t.ts.forEach((n,s)=>{this.es(s,n)})}static Cs(){return new fe(2)}static ys(){return new fe(3)}xs(t){switch(t.ds){case 0:this.us();break;case 1:this.fs(t.Wt);break;case 2:this.Ms(t.Wt);break;case 3:this.gs(t.Wt);break;case 4:this.ws();break;case 5:this.ps(t.Wt);break;case 6:this.vs()}}vs(){const t=this.ns.findIndex(n=>n.ds===5);t!==-1&&this.ns.splice(t,1)}}class Of{formatTickmarks(t){return t.map(n=>this.format(n))}}const Oh=".";function ln(e,t){if(!Ws(e))return"n/a";if(!$i(t))throw new TypeError("invalid length");if(t<0||t>16)throw new TypeError("invalid length");return t===0?e.toString():("0000000000000000"+e.toString()).slice(-t)}class Jr extends Of{constructor(t,n){if(super(),n||(n=1),Ws(t)&&$i(t)||(t=100),t<0)throw new TypeError("invalid base");this.Ki=t,this.Ps=n,this.ks()}format(t){const n=t<0?"−":"";return t=Math.abs(t),n+this.Ts(t)}ks(){if(this.Rs=0,this.Ki>0&&this.Ps>0){let t=this.Ki;for(;t>1;)t/=10,this.Rs++}}Ts(t){const n=this.Ki/this.Ps;let s=Math.floor(t),i="";const r=this.Rs!==void 0?this.Rs:NaN;if(n>1){let o=+(Math.round(t*n)-s*n).toFixed(this.Rs);o>=n&&(o-=n,s+=1),i=Oh+ln(+o.toFixed(this.Rs)*this.Ps,r)}else s=Math.round(s*n)/n,r>0&&(i=Oh+ln(0,r));return s.toFixed(0)+i}}class Uf extends Jr{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Iv extends Of{constructor(t){super(),this.Ds=t}format(t){let n="";return t<0&&(n="-",t=-t),t<995?n+this.Is(t):t<999995?n+this.Is(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),n+this.Is(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),n+this.Is(t/1e9)+"B")}Is(t){let n;const s=Math.pow(10,this.Ds);return n=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Ds).replace(/\.?0+$/,""):String(t),n.replace(/(\.[1-9]*)0+$/,(i,r)=>r)}}const Dv=/[2-9]/g;class Dr{constructor(t=50){this.Vs=0,this.Bs=1,this.Es=1,this.As={},this.Ls=new Map,this.zs=t}Os(){this.Vs=0,this.Ls.clear(),this.Bs=1,this.Es=1,this.As={}}Ii(t,n,s){return this.Ns(t,n,s).width}Di(t,n,s){const i=this.Ns(t,n,s);return((i.actualBoundingBoxAscent||0)-(i.actualBoundingBoxDescent||0))/2}Ns(t,n,s){const i=s||Dv,r=String(n).replace(i,"0");if(this.Ls.has(r))return Re(this.Ls.get(r)).Fs;if(this.Vs===this.zs){const l=this.As[this.Es];delete this.As[this.Es],this.Ls.delete(l),this.Es++,this.Vs--}t.save(),t.textBaseline="middle";const o=t.measureText(r);return t.restore(),o.width===0&&n.length||(this.Ls.set(r,{Fs:o,Ws:this.Bs}),this.As[this.Bs]=r,this.Vs++,this.Bs++),o}}class Lv{constructor(t){this.Hs=null,this.M=null,this.Us="right",this.$s=t}js(t,n,s){this.Hs=t,this.M=n,this.Us=s}st(t){this.M!==null&&this.Hs!==null&&this.Hs.st(t,this.M,this.$s,this.Us)}}class Hf{constructor(t,n,s){this.qs=t,this.$s=new Dr(50),this.Ys=n,this.O=s,this.F=-1,this.Xt=new Lv(this.$s)}Tt(){const t=this.O.Ks(this.Ys);if(t===null)return null;const n=t.Gs(this.Ys)?t.Zs():this.Ys.Ft();if(n===null)return null;const s=t.Xs(n);if(s==="overlay")return null;const i=this.O.Js();return i.P!==this.F&&(this.F=i.P,this.$s.Os()),this.Xt.js(this.qs.qi(),i,s),this.Xt}}class zv extends $n{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Qs(t,n){var o;if(!((o=this.qt)!=null&&o.It))return null;const{ut:s,ct:i,te:r}=this.qt;return n>=s-i-7&&n<=s+i+7?{ie:this.qt,ne:Math.abs(n-s),se:2,ee:"price-line",te:r}:null}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null||this.qt.It===!1)return;const r=Math.round(this.qt.ut*i);r<0||r>n.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*s),Pn(t,this.qt.Gt),Ff(t,r,0,n.width))}}class xl{constructor(t){this.re={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Gt:0,It:!1},this.he=new zv,this.xt=!0,this.ae=t,this.le=t.Qt(),this.he.ht(this.re)}Pt(){this.xt=!0}Tt(){return this.ae.It()?(this.xt&&(this.oe(),this.xt=!1),this.he):null}}class Fv extends xl{constructor(t){super(t)}oe(){this.re.It=!1;const t=this.ae.Ft(),n=t._e()._e;if(n!==2&&n!==3)return;const s=this.ae.N();if(!s.baseLineVisible||!this.ae.It())return;const i=this.ae.Lt();i!==null&&(this.re.It=!0,this.re.ut=t.Nt(i.Wt,i.Wt),this.re.R=s.baseLineColor,this.re.ct=s.baseLineWidth,this.re.Gt=s.baseLineStyle)}}class Bv extends $n{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}ue(){return this.qt}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:s}){const i=this.qt;if(i===null)return;const r=Math.max(1,Math.floor(n)),o=r%2/2,l=Math.round(i.ce.x*n)+o,c=i.ce.y*s;t.fillStyle=i.de,t.beginPath();const h=Math.max(2,1.5*i.fe)*n;t.arc(l,c,h,0,2*Math.PI,!1),t.fill(),t.fillStyle=i.pe,t.beginPath(),t.arc(l,c,i.ft*n,0,2*Math.PI,!1),t.fill(),t.lineWidth=r,t.strokeStyle=i.ve,t.beginPath(),t.arc(l,c,i.ft*n+r/2,0,2*Math.PI,!1),t.stroke()}}const Wv=[{me:0,we:.25,Me:4,ge:10,be:.25,Se:0,xe:.4,Ce:.8},{me:.25,we:.525,Me:10,ge:14,be:0,Se:0,xe:.8,Ce:0},{me:.525,we:1,Me:14,ge:14,be:0,Se:0,xe:0,Ce:0}];class Vv{constructor(t){this.Xt=new Bv,this.xt=!0,this.ye=!0,this.Pe=performance.now(),this.ke=this.Pe-1,this.Te=t}Re(){this.ke=this.Pe-1,this.Pt()}De(){if(this.Pt(),this.Te.N().lastPriceAnimation===2){const t=performance.now(),n=this.ke-t;if(n>0)return void(n<650&&(this.ke+=2600));this.Pe=t,this.ke=t+2600}}Pt(){this.xt=!0}Ie(){this.ye=!0}It(){return this.Te.N().lastPriceAnimation!==0}Ve(){switch(this.Te.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.ke}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ye=!1):this.ye&&(this.Be(),this.ye=!1),this.Xt}Rt(){this.Xt.ht(null);const t=this.Te.Qt().Et(),n=t.Ee(),s=this.Te.Lt();if(n===null||s===null)return;const i=this.Te.Ae(!0);if(i.Le||!n.ze(i.$n))return;const r={x:t.jt(i.$n),y:this.Te.Ft().Nt(i.Mt,s.Wt)},o=i.R,l=this.Te.N().lineWidth,c=this.Oe(this.Ne(),o);this.Xt.ht({de:o,fe:l,pe:c.pe,ve:c.ve,ft:c.ft,ce:r})}Be(){const t=this.Xt.ue();if(t!==null){const n=this.Oe(this.Ne(),t.de);t.pe=n.pe,t.ve=n.ve,t.ft=n.ft}}Ne(){return this.Ve()?performance.now()-this.Pe:2599}Fe(t,n,s,i){const r=s+(i-s)*n;return this.Te.Qt().Xi().Y(t,r)}Oe(t,n){const s=t%2600/2600;let i;for(const h of Wv)if(s>=h.me&&s<=h.we){i=h;break}pe(i!==void 0,"Last price animation internal logic error");const r=(s-i.me)/(i.we-i.me);return{pe:this.Fe(n,r,i.be,i.Se),ve:this.Fe(n,r,i.xe,i.Ce),ft:(o=r,l=i.Me,c=i.ge,l+(c-l)*o)};var o,l,c}}class jv extends xl{constructor(t){super(t)}oe(){const t=this.re;t.It=!1;const n=this.ae.N();if(!n.priceLineVisible||!this.ae.It())return;const s=this.ae.Ae(n.priceLineSource===0);s.Le||(t.It=!0,t.ut=s.Ei,t.R=this.ae.We(s.R),t.ct=n.priceLineWidth,t.Gt=n.priceLineStyle)}}class Ov extends Xr{constructor(t){super(),this.Jt=t}Yi(t,n,s){t.It=!1,n.It=!1;const i=this.Jt;if(!i.It())return;const r=i.N(),o=r.lastValueVisible,l=i.He()!=="",c=r.seriesLastValueMode===0,h=i.Ae(!1);if(h.Le)return;o&&(t.ri=this.Ue(h,o,c),t.It=t.ri.length!==0),(l||c)&&(n.ri=this.$e(h,o,l,c),n.It=n.ri.length>0);const a=i.We(h.R),u=this.Jt.Qt().Xi().G(a);s.Z=u.Z,s.Ei=h.Ei,n.Ht=i.Qt().Ut(h.Ei/i.Ft().$t()),t.Ht=a,t.R=u.X,n.R=u.X}$e(t,n,s,i){let r="";const o=this.Jt.He();return s&&o.length!==0&&(r+=`${o} `),n&&i&&(r+=this.Jt.Ft().je()?t.qe:t.Ye),r.trim()}Ue(t,n,s){return n?s?this.Jt.Ft().je()?t.Ye:t.qe:t.ri:""}}function Uh(e,t,n,s){const i=Number.isFinite(t),r=Number.isFinite(n);return i&&r?e(t,n):i||r?i?t:n:s}class ke{constructor(t,n){this.Ke=t,this.Ge=n}Ze(t){return t!==null&&this.Ke===t.Ke&&this.Ge===t.Ge}Xe(){return new ke(this.Ke,this.Ge)}Je(){return this.Ke}Qe(){return this.Ge}tr(){return this.Ge-this.Ke}Zi(){return this.Ge===this.Ke||Number.isNaN(this.Ge)||Number.isNaN(this.Ke)}Ss(t){return t===null?this:new ke(Uh(Math.min,this.Je(),t.Je(),-1/0),Uh(Math.max,this.Qe(),t.Qe(),1/0))}ir(t){if(!Ws(t)||this.Ge-this.Ke===0)return;const n=.5*(this.Ge+this.Ke);let s=this.Ge-n,i=this.Ke-n;s*=t,i*=t,this.Ge=n+s,this.Ke=n+i}nr(t){Ws(t)&&(this.Ge+=t,this.Ke+=t)}sr(){return{minValue:this.Ke,maxValue:this.Ge}}static er(t){return t===null?null:new ke(t.minValue,t.maxValue)}}class Lr{constructor(t,n){this.rr=t,this.hr=n||null}ar(){return this.rr}lr(){return this.hr}sr(){return{priceRange:this.rr===null?null:this.rr.sr(),margins:this.hr||void 0}}static er(t){return t===null?null:new Lr(ke.er(t.priceRange),t.margins)}}const Uv=[2,4,8,16,32,64,128,256,512],Hv="Custom series with conflation reducer must have a priceValueBuilder method";class qv extends xl{constructor(t,n){super(t),this._r=n}oe(){const t=this.re;t.It=!1;const n=this._r.N();if(!this.ae.It()||!n.lineVisible)return;const s=this._r.ur();s!==null&&(t.It=!0,t.ut=s,t.R=n.color,t.ct=n.lineWidth,t.Gt=n.lineStyle,t.te=this._r.N().id)}}class Gv extends Xr{constructor(t,n){super(),this.Te=t,this._r=n}Yi(t,n,s){t.It=!1,n.It=!1;const i=this._r.N(),r=i.axisLabelVisible,o=i.title!=="",l=this.Te;if(!r||!l.It())return;const c=this._r.ur();if(c===null)return;o&&(n.ri=i.title,n.It=!0),n.Ht=l.Qt().Ut(c/l.Ft().$t()),t.ri=this.cr(i.price),t.It=!0;const h=this.Te.Qt().Xi().G(i.axisLabelColor||i.color);s.Z=h.Z;const a=i.axisLabelTextColor||h.X;t.R=a,n.R=a,s.Ei=c}cr(t){const n=this.Te.Lt();return n===null?"":this.Te.Ft().Ji(t,n.Wt)}}class Yv{constructor(t,n){this.Te=t,this.yn=n,this.dr=new qv(t,this),this.qs=new Gv(t,this),this.pr=new Hf(this.qs,t,t.Qt())}vr(t){$e(this.yn,t),this.Pt(),this.Te.Qt().mr()}N(){return this.yn}wr(){return this.dr}Mr(){return this.pr}gr(){return this.qs}Pt(){this.dr.Pt(),this.qs.Pt()}ur(){const t=this.Te,n=t.Ft();if(t.Qt().Et().Zi()||n.Zi())return null;const s=t.Lt();return s===null?null:n.Nt(this.yn.price,s.Wt)}}class Xv{constructor(){this.br=new WeakMap}Sr(t,n,s){const i=1/n*s;if(t>=i)return 1;const r=i/t,o=Math.pow(2,Math.floor(Math.log2(r)));return Math.min(o,512)}Cr(t,n,s,i=!1,r){if(t.length===0||n<=1)return t;const o=this.yr(n);if(o<=1)return t;const l=this.Pr(t);let c=l.kr.get(o);return c!==void 0||(c=this.Tr(t,o,s,i,r,l.kr),l.kr.set(o,c)),c}Rr(t,n,s,i,r=!1,o){if(s<1||t.length===0)return t;const l=this.Pr(t),c=l.kr.get(s);if(!c)return this.Cr(t,s,i,r,o);const h=this.Dr(t,n,s,c,r,i,o);return l.kr.set(s,h),h}yr(t){if(t<=2)return 2;for(const n of Uv)if(t<=n)return n;return 512}Ir(t){if(t.length===0)return 0;const n=t[0],s=t[t.length-1];return 31*t.length+17*n.$n+13*s.$n}Tr(t,n,s,i=!1,r,o=new Map){if(n===2)return this.Vr(t,2,s,i,r);const l=n/2;let c=o.get(l);return c||(c=this.Tr(t,l,s,i,r,o),o.set(l,c)),this.Br(c,s,i,r)}Vr(t,n,s,i=!1,r){const o=this.Er(t,n,s,i,r);return this.Ar(o,i)}Br(t,n,s=!1,i){const r=this.Er(t,2,n,s,i);return this.Ar(r,s)}Er(t,n,s,i=!1,r){const o=[];for(let l=0;l<t.length;l+=n)if(t.length-l>=n){const c=this.Lr(t[l],t[l+1],s,i,r);c.zr=!1,o.push(c)}else if(o.length===0)o.push(this.Or(t[l],!0));else{const c=o[o.length-1];o[o.length-1]=this.Nr(c,t[l],s,i,r)}return o}Fr(t,n){return(t??1)+(n??1)}Lr(t,n,s,i=!1,r){if(!i||!s||!r){const h=t.Wt[1]>n.Wt[1]?t.Wt[1]:n.Wt[1],a=t.Wt[2]<n.Wt[2]?t.Wt[2]:n.Wt[2];return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:h,Yr:a,Kr:n.Wt[3],Gr:this.Fr(t.Gr,n.Gr),Zr:void 0,zr:!1}}const o=s(this.Xr(t,r),this.Xr(n,r)),l=r(o),c=l.length?l[l.length-1]:0;return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:Math.max(t.Wt[1],c),Yr:Math.min(t.Wt[2],c),Kr:c,Gr:this.Fr(t.Gr,n.Gr),Zr:o,zr:!1}}Nr(t,n,s,i=!1,r){if(!i||!s||!r)return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:t.qr>n.Wt[1]?t.qr:n.Wt[1],Yr:t.Yr<n.Wt[2]?t.Yr:n.Wt[2],Kr:n.Wt[3],Gr:t.Gr+(n.Gr??1),Zr:t.Zr,zr:!1};const o=t.Zr,l=this.Xr(n,r),c=o?{data:o,index:t.Wr,originalTime:t.Ur,time:t.Ur,priceValues:r(o)}:null,h=c?s(c,l):l.data,a=c?r(h):l.priceValues,u=a.length?a[a.length-1]:0;return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:Math.max(t.qr,u),Yr:Math.min(t.Yr,u),Kr:u,Gr:t.Gr+(n.Gr??1),Zr:h,zr:!1}}Jr(t,n,s,i,r,o,l=!1,c){const h=n===i?r:t[n];if(s-n==1)return this.Or(h,!0);const a=n+1===i?r:t[n+1];let u=this.Lr(h,a,o,l,c);for(let f=n+2;f<s;f++){const p=f===i?r:t[f];u=this.Nr(u,p,o,l,c)}return u}Xr(t,n){const s=t.ue??{};return{data:t.ue,index:t.$n,originalTime:t.Qr,time:t.wt,priceValues:n(s)}}th(t,n=!1){const s=n===!0,i=!!t.Zr;return{$n:t.Wr,wt:t.Ur,Qr:t.Ur,Wt:[s?t.Kr:t.jr,t.qr,t.Yr,t.Kr],Gr:t.Gr,ue:s?i?t.Zr:{wt:t.Ur}:void 0}}Ar(t,n=!1){return t.map(s=>this.th(s,n))}Dr(t,n,s,i,r=!1,o,l){if(i.length===0)return i;const c=t.length-1,h=Math.floor(c/s)*s;if(Math.min(h+s,t.length)-h<s&&t.length>s){const a=t.slice();return a[a.length-1]=n,this.Cr(a,s,o,r,l)}if(Math.floor((c-1)/s)===Math.floor(c/s)||i.length===1){const a=Math.min(h+s,t.length),u=a-h;if(u<=0)return i;const f=u===1?this.Or(h===c?n:t[h],!0):this.Jr(t,h,a,c,n,o,r,l);return i[i.length-1]=this.th(f,r),i}{const a=t.slice();return a[a.length-1]=n,this.Cr(a,s,o,r,l)}}Or(t,n=!1){return{Wr:t.$n,Hr:t.$n,Ur:t.wt,$r:t.wt,jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3],Gr:t.Gr??1,Zr:t.ue,zr:n}}Pr(t){const n=this.ih(t),s=this.Ir(t);return n.nh!==s&&(n.kr.clear(),n.nh=s),n}ih(t){let n=this.br.get(t);return n===void 0&&(n={nh:this.Ir(t),kr:new Map},this.br.set(t,n)),n}}class Qv extends jf{constructor(t){super(),this.sn=t}Qt(){return this.sn}}const Jv={Bar:(e,t,n,s)=>{const i=t.upColor,r=t.downColor,o=K(e(n,s)),l=Mn(o.Wt[0])<=Mn(o.Wt[3]);return{sh:o.R??(l?i:r)}},Candlestick:(e,t,n,s)=>{const i=t.upColor,r=t.downColor,o=t.borderUpColor,l=t.borderDownColor,c=t.wickUpColor,h=t.wickDownColor,a=K(e(n,s)),u=Mn(a.Wt[0])<=Mn(a.Wt[3]);return{sh:a.R??(u?i:r),eh:a.Ht??(u?o:l),rh:a.hh??(u?c:h)}},Custom:(e,t,n,s)=>({sh:K(e(n,s)).R??t.color}),Area:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.vt??t.lineColor,vt:i.vt??t.lineColor,ah:i.ah??t.topColor,oh:i.oh??t.bottomColor}},Baseline:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.Wt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,_h:i._h??t.topLineColor,uh:i.uh??t.bottomLineColor,dh:i.dh??t.topFillColor1,fh:i.fh??t.topFillColor2,ph:i.ph??t.bottomFillColor1,mh:i.mh??t.bottomFillColor2}},Line:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.R??t.color,vt:i.R??t.color}},Histogram:(e,t,n,s)=>({sh:K(e(n,s)).R??t.color})};class Kv{constructor(t){this.wh=(n,s)=>s!==void 0?s.Wt:this.Te.Un().Mh(n),this.Te=t,this.gh=Jv[t.bh()]}Sh(t,n){return this.gh(this.wh,this.Te.N(),t,n)}}function qf(e,t,n,s,i=0,r=t.length){let o=r-i;for(;0<o;){const l=o>>1,c=i+l;s(t[c],n)===e?(i=c+1,o-=l+1):o=l}return i}const es=qf.bind(null,!0),wl=qf.bind(null,!1);var Hh;(function(e){e[e.NearestLeft=-1]="NearestLeft",e[e.None=0]="None",e[e.NearestRight=1]="NearestRight"})(Hh||(Hh={}));const Sn=30;class Zv{constructor(){this.xh=[],this.Ch=new Map,this.yh=new Map,this.Ph=[]}kh(){return this.Th()>0?this.xh[this.xh.length-1]:null}Rh(){return this.Th()>0?this.Dh(0):null}Qn(){return this.Th()>0?this.Dh(this.xh.length-1):null}Th(){return this.xh.length}Zi(){return this.Th()===0}ze(t){return this.Ih(t,0)!==null}Mh(t){return this.Hn(t)}Hn(t,n=0){const s=this.Ih(t,n);return s===null?null:{...this.Vh(s),$n:this.Dh(s)}}Bh(){return this.xh}Eh(t,n,s){if(this.Zi())return null;let i=null;for(const r of s)i=ar(i,this.Ah(t,n,r));return i}ht(t){this.yh.clear(),this.Ch.clear(),this.xh=t,this.Ph=t.map(n=>n.$n)}Lh(){return this.Ph}Dh(t){return this.xh[t].$n}Vh(t){return this.xh[t]}Ih(t,n){const s=this.zh(t);if(s===null&&n!==0)switch(n){case-1:return this.Oh(t);case 1:return this.Nh(t);default:throw new TypeError("Unknown search mode")}return s}Oh(t){let n=this.Fh(t);return n>0&&(n-=1),n!==this.xh.length&&this.Dh(n)<t?n:null}Nh(t){const n=this.Wh(t);return n!==this.xh.length&&t<this.Dh(n)?n:null}zh(t){const n=this.Fh(t);return n===this.xh.length||t<this.xh[n].$n?null:n}Fh(t){return es(this.xh,t,(n,s)=>n.$n<s)}Wh(t){return wl(this.xh,t,(n,s)=>n.$n>s)}Hh(t,n,s){let i=null;for(let r=t;r<n;r++){const o=this.xh[r].Wt[s];Number.isNaN(o)||(i===null?i={Uh:o,$h:o}:(o<i.Uh&&(i.Uh=o),o>i.$h&&(i.$h=o)))}return i}Ah(t,n,s){if(this.Zi())return null;let i=null;const r=K(this.Rh()),o=K(this.Qn()),l=Math.max(t,r),c=Math.min(n,o),h=Math.ceil(l/Sn)*Sn,a=Math.max(h,Math.floor(c/Sn)*Sn);{const f=this.Fh(l),p=this.Wh(Math.min(c,h,n));i=ar(i,this.Hh(f,p,s))}let u=this.Ch.get(s);u===void 0&&(u=new Map,this.Ch.set(s,u));for(let f=Math.max(h+1,l);f<a;f+=Sn){const p=Math.floor(f/Sn);let g=u.get(p);if(g===void 0){const d=this.Fh(p*Sn),w=this.Wh((p+1)*Sn-1);g=this.Hh(d,w,s),u.set(p,g)}i=ar(i,g)}{const f=this.Fh(a),p=this.Wh(c);i=ar(i,this.Hh(f,p,s))}return i}}function ar(e,t){return e===null?t:t===null?e:{Uh:Math.min(e.Uh,t.Uh),$h:Math.max(e.$h,t.$h)}}function _o(){return new Zv}const zr={setLineStyle:Pn};class tx{constructor(t){this.jh=t}st(t,n,s){this.jh.draw(t,zr)}qh(t,n,s){var i,r;(r=(i=this.jh).drawBackground)==null||r.call(i,t,zr)}}class ex{constructor(t){this.Ls=null,this.Yh=t}Tt(){var s;const t=this.Yh.renderer();if(t===null)return null;if(((s=this.Ls)==null?void 0:s.Kh)===t)return this.Ls.Gh;const n=new tx(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}class Gf{constructor(t){this.Xh=null,this.Jh=t}Qh(){return this.Jh}Nn(){var t,n;(n=(t=this.Jh).updateAllViews)==null||n.call(t)}jn(){var s,i,r;const t=((i=(s=this.Jh).paneViews)==null?void 0:i.call(s))??[];if(((r=this.Xh)==null?void 0:r.Kh)===t)return this.Xh.Gh;const n=t.map(o=>new ex(o));return this.Xh={Kh:t,Gh:n},n}Qs(t,n){var s,i;return((i=(s=this.Jh).hitTest)==null?void 0:i.call(s,t,n))??null}}let nx=class extends Gf{cn(){return[]}};class sx{constructor(t){this.jh=t}st(t,n,s){this.jh.draw(t,zr)}qh(t,n,s){var i,r;(r=(i=this.jh).drawBackground)==null||r.call(i,t,zr)}}class qh{constructor(t){this.Ls=null,this.Yh=t}Tt(){var s;const t=this.Yh.renderer();if(t===null)return null;if(((s=this.Ls)==null?void 0:s.Kh)===t)return this.Ls.Gh;const n=new sx(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}function Yf(e){var t,n,s;return{ri:e.text(),Ei:e.coordinate(),Vi:(t=e.fixedCoordinate)==null?void 0:t.call(e),R:e.textColor(),Z:e.backColor(),It:((n=e.visible)==null?void 0:n.call(e))??!0,pi:((s=e.tickVisible)==null?void 0:s.call(e))??!0}}class ix{constructor(t,n){this.Xt=new Vf,this.ta=t,this.ia=n}Tt(){return this.Xt.ht({nn:this.ia.nn(),...Yf(this.ta)}),this.Xt}}class rx extends Xr{constructor(t,n){super(),this.ta=t,this.Ki=n}Yi(t,n,s){const i=Yf(this.ta);s.Z=i.Z,t.R=i.R;const r=2/12*this.Ki.P();s.Ti=r,s.Ri=r,s.Ei=i.Ei,s.Vi=i.Vi,t.ri=i.ri,t.It=i.It,t.pi=i.pi}}class ox extends Gf{constructor(t,n){super(t),this.na=null,this.sa=null,this.ea=null,this.ra=null,this.Te=n}dn(){var i,r,o;const t=((r=(i=this.Jh).timeAxisViews)==null?void 0:r.call(i))??[];if(((o=this.na)==null?void 0:o.Kh)===t)return this.na.Gh;const n=this.Te.Qt().Et(),s=t.map(l=>new ix(l,n));return this.na={Kh:t,Gh:s},s}qn(){var i,r,o;const t=((r=(i=this.Jh).priceAxisViews)==null?void 0:r.call(i))??[];if(((o=this.sa)==null?void 0:o.Kh)===t)return this.sa.Gh;const n=this.Te.Ft(),s=t.map(l=>new rx(l,n));return this.sa={Kh:t,Gh:s},s}ha(){var s,i,r;const t=((i=(s=this.Jh).priceAxisPaneViews)==null?void 0:i.call(s))??[];if(((r=this.ea)==null?void 0:r.Kh)===t)return this.ea.Gh;const n=t.map(o=>new qh(o));return this.ea={Kh:t,Gh:n},n}aa(){var s,i,r;const t=((i=(s=this.Jh).timeAxisPaneViews)==null?void 0:i.call(s))??[];if(((r=this.ra)==null?void 0:r.Kh)===t)return this.ra.Gh;const n=t.map(o=>new qh(o));return this.ra={Kh:t,Gh:n},n}la(t,n){var s,i;return((i=(s=this.Jh).autoscaleInfo)==null?void 0:i.call(s,t,n))??null}}function lr(e,t,n,s){e.forEach(i=>{t(i).forEach(r=>{r.Zh()===n&&s.push(r)})})}function cr(e){return e.jn()}function ax(e){return e.ha()}function lx(e){return e.aa()}const cx=["Area","Line","Baseline"];class Kr extends Qv{constructor(t,n,s,i,r){super(t),this.qt=_o(),this.dr=new jv(this),this.oa=[],this._a=new Fv(this),this.ua=null,this.ca=null,this.da=null,this.fa=[],this.pa=new Xv,this.va=new Map,this.ma=null,this.yn=s,this.wa=n;const o=new Ov(this);if(this.mn=[o],this.pr=new Hf(o,this,t),cx.includes(this.wa)&&(this.ua=new Vv(this)),this.Ma(),this.Yh=i(this,this.Qt(),r),this.wa==="Custom"){const l=this.Yh;l.ga&&this.ba(l.ga)}}m(){this.da!==null&&clearTimeout(this.da)}We(t){return this.yn.priceLineColor||t}Ae(t){const n={Le:!0},s=this.Ft();if(this.Qt().Et().Zi()||s.Zi()||this.qt.Zi())return n;const i=this.Qt().Et().Ee(),r=this.Lt();if(i===null||r===null)return n;let o,l;if(t){const u=this.qt.kh();if(u===null)return n;o=u,l=u.$n}else{const u=this.qt.Hn(i.bi(),-1);if(u===null||(o=this.qt.Mh(u.$n),o===null))return n;l=u.$n}const c=o.Wt[3],h=this.Sa().Sh(l,{Wt:o}),a=s.Nt(c,r.Wt);return{Le:!1,Mt:c,ri:s.Ji(c,r.Wt),qe:s.xa(c),Ye:s.Ca(c,r.Wt),R:h.sh,Ei:a,$n:l}}Sa(){return this.ca!==null||(this.ca=new Kv(this)),this.ca}N(){return this.yn}vr(t){const n=this.Qt(),{priceScaleId:s,visible:i,priceFormat:r}=t;s!==void 0&&s!==this.yn.priceScaleId&&n.ya(this,s),i!==void 0&&i!==this.yn.visible&&n.Pa();const o=t.conflationThresholdFactor!==void 0;$e(this.yn,t),Object.prototype.hasOwnProperty.call(t,"autoscaleInfoProvider")&&t.autoscaleInfoProvider===void 0&&(this.yn.autoscaleInfoProvider=void 0),o&&(this.va.clear(),this.Qt().mr()),r!==void 0&&(this.Ma(),n.ka()),n.Ta(this),n.Ra(),this.Yh.Pt("options")}ht(t,n){this.qt.ht(t),this.va.clear();const s=this.Qt().Et().N();s.enableConflation&&s.precomputeConflationOnInit&&this.Da(s.precomputeConflationPriority),this.Ia(),this.ua!==null&&(n&&n.Va?this.ua.De():t.length===0&&this.ua.Re());const i=this.Qt().Ks(this);this.Qt().Ba(i),this.Qt().Ta(this),this.Qt().Ra(),this.Qt().mr()}Ia(){this.Yh.Pt("data")}Ea(t){const n=new Yv(this,t);return this.oa.push(n),this.Qt().Ta(this),n}Aa(t){const n=this.oa.indexOf(t);n!==-1&&this.oa.splice(n,1),this.Qt().Ta(this)}La(){return this.oa}bh(){return this.wa}Lt(){const t=this.za();return t===null?null:{Wt:t.Wt[3],Oa:t.wt}}za(){const t=this.Qt().Et().Ee();if(t===null)return null;const n=t.Na();return this.qt.Hn(n,1)}Un(){return this.qt}ba(t){this.ma=t,this.va.clear()}Fa(){return!!this.Qt().Et().N().enableConflation&&this.Wa()>1}Rr(t){if(!this.Fa())return;const n=this.Wa();if(!this.va.has(n))return;const s=this.wa==="Custom",i=s&&this.ma||void 0,r=s&&this.Yh.Ha?c=>{const h=c,a=this.Yh.Ha(h);return Array.isArray(a)?a:[typeof a=="number"?a:0]}:void 0,o=this.pa.Rr(this.qt.Bh(),t,n,i,s,r),l=_o();l.ht(o),this.va.set(n,l)}Ua(){const t=this.Qt().Et().N().enableConflation;if(this.wa==="Custom"&&this.ma===null)return this.qt;if(!t)return this.qt;const n=this.Wa(),s=this.va.get(n);return s||(this.$a(n),this.va.get(n)??this.qt)}ja(t){const n=this.qt.Mh(t);return n===null?null:this.wa==="Bar"||this.wa==="Candlestick"||this.wa==="Custom"?{jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3]}:n.Wt[3]}qa(t){const n=[];lr(this.fa,cr,"top",n);const s=this.ua;return s!==null&&s.It()&&(this.da===null&&s.Ve()&&(this.da=setTimeout(()=>{this.da=null,this.Qt().Ya()},0)),s.Ie(),n.unshift(s)),n}jn(){const t=[];this.Ka()||t.push(this._a),t.push(this.Yh,this.dr);const n=this.oa.map(s=>s.wr());return t.push(...n),lr(this.fa,cr,"normal",t),t}Ga(){var r,o;const t=((o=(r=this.Yh).Ga)==null?void 0:o.call(r))??null;if(t===null)return null;const n=[];this.Ka()||n.push(this._a),n.push(...t.Za),lr(this.fa,cr,"normal",n);const s=[];s.push(...t.qa,this.dr);const i=this.oa.map(l=>l.wr());return s.push(...i),{Za:n,qa:s}}Xa(){return this.Ja(cr,"bottom")}Qa(t){return this.Ja(ax,t)}tl(t){return this.Ja(lx,t)}il(t,n){return this.fa.map(s=>s.Qs(t,n)).filter(s=>s!==null)}cn(){return[this.pr,...this.oa.map(t=>t.Mr())]}qn(t,n){if(n!==this.hn&&!this.Ka())return[];const s=[...this.mn];for(const i of this.oa)s.push(i.gr());return this.fa.forEach(i=>{s.push(...i.qn())}),s}dn(){const t=[];return this.fa.forEach(n=>{t.push(...n.dn())}),t}la(t,n){if(this.yn.autoscaleInfoProvider!==void 0){const s=this.yn.autoscaleInfoProvider(()=>{const i=this.nl(t,n);return i===null?null:i.sr()});return Lr.er(s)}return this.nl(t,n)}Kh(){const t=this.yn.priceFormat;return t.base??1/t.minMove}sl(){return this.el}Nn(){var t;this.Yh.Pt();for(const n of this.mn)n.Pt();for(const n of this.oa)n.Pt();this.dr.Pt(),this._a.Pt(),(t=this.ua)==null||t.Pt(),this.fa.forEach(n=>n.Nn())}Ft(){return K(super.Ft())}At(t){if(!((this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline")&&this.yn.crosshairMarkerVisible))return null;const n=this.qt.Mh(t);return n===null?null:{Mt:n.Wt[3],ft:this.rl(),Ht:this.hl(),Ot:this.al(),zt:this.ll(t)}}He(){return this.yn.title}It(){return this.yn.visible}ol(t){this.fa.push(new ox(t,this))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t)}ul(){if(this.wa==="Custom")return t=>this.Yh.Ha(t)}cl(){if(this.wa==="Custom")return t=>this.Yh.dl(t)}fl(){return this.qt.Lh()}Ka(){return!Qr(this.Ft().pl())}nl(t,n){if(!$i(t)||!$i(n)||this.qt.Zi())return null;const s=this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline"||this.wa==="Histogram"?[3]:[2,1],i=this.qt.Eh(t,n,s);let r=i!==null?new ke(i.Uh,i.$h):null,o=null;if(this.bh()==="Histogram"){const l=this.yn.base,c=new ke(l,l);r=r!==null?r.Ss(c):c}return this.fa.forEach(l=>{const c=l.la(t,n);if(c!=null&&c.priceRange){const h=new ke(c.priceRange.minValue,c.priceRange.maxValue);r=r!==null?r.Ss(h):h}c!=null&&c.margins&&(o=c.margins)}),new Lr(r,o)}rl(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerRadius}return 0}hl(){switch(this.wa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBorderColor;if(t.length!==0)return t}}return null}al(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerBorderWidth}return 0}ll(t){switch(this.wa){case"Line":case"Area":case"Baseline":{const n=this.yn.crosshairMarkerBackgroundColor;if(n.length!==0)return n}}return this.Sa().Sh(t).sh}Ma(){switch(this.yn.priceFormat.type){case"custom":{const t=this.yn.priceFormat.formatter;this.el={format:t,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(n=>n.map(t))};break}case"volume":this.el=new Iv(this.yn.priceFormat.precision);break;case"percent":this.el=new Uf(this.yn.priceFormat.precision);break;default:{const t=Math.pow(10,this.yn.priceFormat.precision);this.el=new Jr(t,this.yn.priceFormat.minMove*t)}}this.hn!==null&&this.hn.vl()}Ja(t,n){const s=[];return lr(this.fa,t,n,s),s}Wa(){const{ml:t,wl:n,Ml:s}=this.gl();return this.pa.Sr(t,n,s)}gl(){const t=this.Qt().Et(),n=t.ml(),s=window.devicePixelRatio||1,i=t.N().conflationThresholdFactor;return{ml:n,wl:s,Ml:this.yn.conflationThresholdFactor??i??1}}bl(t){const n=this.qt.Bh();let s;if(this.wa==="Custom"&&this.ma!==null){const r=this.ul();if(!r)throw new Error(Hv);s=this.pa.Cr(n,t,this.ma,!0,o=>r(o))}else s=this.pa.Cr(n,t);const i=_o();return i.ht(s),i}$a(t){const n=this.bl(t);this.va.set(t,n)}Da(t){var s;if(this.wa==="Custom"&&(this.ma===null||!this.ul()))return;this.va.clear();const n=this.Qt().Et().Sl();for(const i of n){const r=()=>{this.xl(i)},o=typeof window=="object"&&window||typeof self=="object"&&self;(s=o==null?void 0:o.yl)!=null&&s.Cl?o.yl.Cl(()=>{r()},{se:t}):Promise.resolve().then(()=>r())}}xl(t){if(this.va.has(t)||this.qt.Bh().length===0)return;const n=this.bl(t);this.va.set(t,n)}}const hx=[3],ux=[0,1,2,3];class dx{constructor(t){this.yn=t}Pl(t,n,s){let i=t;if(this.yn.mode===0)return i;const r=s.kn(),o=r.Lt();if(o===null)return i;const l=r.Nt(t,o),c=s.kl().filter(a=>a instanceof Kr).reduce((a,u)=>{if(s.Gs(u)||!u.It())return a;const f=u.Ft(),p=u.Un();if(f.Zi()||!p.ze(n))return a;const g=p.Mh(n);if(g===null)return a;const d=Mn(u.Lt()),w=this.yn.mode===3?ux:hx;return a.concat(w.map(C=>f.Nt(g.Wt[C],d.Wt)))},[]);if(c.length===0)return i;c.sort((a,u)=>Math.abs(a-l)-Math.abs(u-l));const h=c[0];return i=r.Tn(h,o),i}}function Ds(e,t,n){return Math.min(Math.max(e,t),n)}function hr(e,t,n){return t-e<=n}class fx extends $n{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(o,l){o.save(),o.lineWidth%2&&o.translate(.5,.5),l(),o.restore()}(t,()=>{const o=K(this.qt);if(o.Tl){t.strokeStyle=o.Rl,Pn(t,o.Dl),t.beginPath();for(const l of o.Il){const c=Math.round(l.Vl*s);t.moveTo(c,-r),t.lineTo(c,n.height+r)}t.stroke()}if(o.Bl){t.strokeStyle=o.El,Pn(t,o.Al),t.beginPath();for(const l of o.Ll){const c=Math.round(l.Vl*i);t.moveTo(-r,c),t.lineTo(n.width+r,c)}t.stroke()}})}}class mx{constructor(t){this.Xt=new fx,this.xt=!0,this.yt=t}Pt(){this.xt=!0}Tt(){if(this.xt){const t=this.yt.Qt().N().grid,n={Bl:t.horzLines.visible,Tl:t.vertLines.visible,El:t.horzLines.color,Rl:t.vertLines.color,Al:t.horzLines.style,Dl:t.vertLines.style,Ll:this.yt.kn().zl(),Il:(this.yt.Qt().Et().zl()||[]).map(s=>({Vl:s.coord}))};this.Xt.ht(n),this.xt=!1}return this.Xt}}class px{constructor(t){this.Yh=new mx(t)}wr(){return this.Yh}}const $o={Ol:4,Nl:1e-4};function $s(e,t){const n=100*(e-t)/t;return t<0?-n:n}function gx(e,t){const n=$s(e.Je(),t),s=$s(e.Qe(),t);return new ke(n,s)}function xi(e,t){const n=100*(e-t)/t+100;return t<0?-n:n}function yx(e,t){const n=xi(e.Je(),t),s=xi(e.Qe(),t);return new ke(n,s)}function Fr(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const s=Math.log10(n+t.Nl)+t.Ol;return e<0?-s:s}function wi(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const s=Math.pow(10,n-t.Ol)-t.Nl;return e<0?-s:s}function ai(e,t){if(e===null)return null;const n=Fr(e.Je(),t),s=Fr(e.Qe(),t);return new ke(n,s)}function Ns(e,t){if(e===null)return null;const n=wi(e.Je(),t),s=wi(e.Qe(),t);return new ke(n,s)}function No(e){if(e===null)return $o;const t=Math.abs(e.Qe()-e.Je());if(t>=1||t<1e-15)return $o;const n=Math.ceil(Math.abs(Math.log10(t))),s=$o.Ol+n;return{Ol:s,Nl:1/Math.pow(10,s)}}class Io{constructor(t,n){if(this.Fl=t,this.Wl=n,function(s){if(s<0)return!1;if(s>1e18)return!0;for(let i=s;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Fl))this.Hl=[2,2.5,2];else{this.Hl=[];for(let s=this.Fl;s!==1;){if(s%2==0)this.Hl.push(2),s/=2;else{if(s%5!=0)throw new Error("unexpected base");this.Hl.push(2,2.5),s/=5}if(this.Hl.length>100)throw new Error("something wrong with base")}}}Ul(t,n,s){const i=this.Fl===0?0:1/this.Fl;let r=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-n)))),o=0,l=this.Wl[0];for(;;){const u=hr(r,i,1e-14)&&r>i+1e-14,f=hr(r,s*l,1e-14),p=hr(r,1,1e-14);if(!(u&&f&&p))break;r/=l,l=this.Wl[++o%this.Wl.length]}if(r<=i+1e-14&&(r=i),r=Math.max(1,r),this.Hl.length>0&&(c=r,h=1,a=1e-14,Math.abs(c-h)<a))for(o=0,l=this.Hl[0];hr(r,s*l,1e-14)&&r>i+1e-14;)r/=l,l=this.Hl[++o%this.Hl.length];var c,h,a;return r}}class Gh{constructor(t,n,s,i){this.$l=[],this.Ki=t,this.Fl=n,this.jl=s,this.ql=i}Ul(t,n){if(t<n)throw new Error("high < low");const s=this.Ki.$t(),i=(t-n)*this.Yl()/s,r=new Io(this.Fl,[2,2.5,2]),o=new Io(this.Fl,[2,2,2.5]),l=new Io(this.Fl,[2.5,2,2]),c=[];return c.push(r.Ul(t,n,i),o.Ul(t,n,i),l.Ul(t,n,i)),function(h){if(h.length<1)throw Error("array is empty");let a=h[0];for(let u=1;u<h.length;++u)h[u]<a&&(a=h[u]);return a}(c)}Kl(){const t=this.Ki,n=t.Lt();if(n===null)return void(this.$l=[]);const s=t.$t(),i=this.jl(s-1,n),r=this.jl(0,n),o=this.Ki.N().entireTextOnly?this.Gl()/2:0,l=o,c=s-1-o,h=Math.max(i,r),a=Math.min(i,r);if(h===a)return void(this.$l=[]);const u=this.Ul(h,a);if(this.Zl(n,u,h,a,l,c),t.Xl()&&this.Jl(u,a,h)){const g=this.Ki.Ql();this.io(n,u,l,c,g,2*g)}const f=this.$l.map(g=>g.no),p=this.Ki.so(f);for(let g=0;g<this.$l.length;g++)this.$l[g].eo=p[g]}zl(){return this.$l}Gl(){return this.Ki.P()}Yl(){return Math.ceil(this.Gl()*this.Ki.N().tickMarkDensity)}Zl(t,n,s,i,r,o){const l=this.$l,c=this.Ki;let h=s%n;h+=h<0?n:0;const a=s>=i?1:-1;let u=null,f=0;for(let p=s-h;p>i;p-=n){const g=this.ql(p,t,!0);u!==null&&Math.abs(g-u)<this.Yl()||g<r||g>o||(f<l.length?(l[f].Vl=g,l[f].eo=c.ro(p),l[f].no=p):l.push({Vl:g,eo:c.ro(p),no:p}),f++,u=g,c.ho()&&(n=this.Ul(p*a,i)))}l.length=f}io(t,n,s,i,r,o){const l=this.$l,c=this.ao(t,s,r,o),h=this.ao(t,i,-o,-r),a=this.ql(0,t,!0)-this.ql(n,t,!0);l.length>0&&l[0].Vl-c.Vl<a/2&&l.shift(),l.length>0&&h.Vl-l[l.length-1].Vl<a/2&&l.pop(),l.unshift(c),l.push(h)}ao(t,n,s,i){const r=(s+i)/2,o=this.jl(n+s,t),l=this.jl(n+i,t),c=Math.min(o,l),h=Math.max(o,l),a=Math.max(.1,this.Ul(h,c)),u=this.jl(n+r,t),f=u-u%a,p=this.ql(f,t,!0);return{eo:this.Ki.ro(f),Vl:p,no:f}}Jl(t,n,s){let i=Mn(this.Ki.ar());return this.Ki.ho()&&(i=Ns(i,this.Ki.lo())),i.Je()-n<t&&s-i.Qe()<t}}function Xf(e){return e.slice().sort((t,n)=>K(t.ln())-K(n.ln()))}var Yh;(function(e){e[e.Normal=0]="Normal",e[e.Logarithmic=1]="Logarithmic",e[e.Percentage=2]="Percentage",e[e.IndexedTo100=3]="IndexedTo100"})(Yh||(Yh={}));const Xh=new Uf,Qh=new Jr(100,1);class bx{constructor(t,n,s,i,r){this.oo=0,this._o=null,this.rr=null,this.uo=null,this.co={do:!1,fo:null},this.po=!1,this.vo=0,this.mo=0,this.wo=new Zt,this.Mo=new Zt,this.bo=[],this.So=null,this.xo=null,this.Co=null,this.yo=null,this.Po=null,this.el=Qh,this.ko=No(null),this.To=t,this.yn=n,this.Ro=s,this.Do=i,this.Io=r,this.Vo=new Gh(this,100,this.Bo.bind(this),this.Eo.bind(this))}pl(){return this.To}N(){return this.yn}vr(t){if($e(this.yn,t),this.vl(),t.mode!==void 0&&this.Ao({_e:t.mode}),t.scaleMargins!==void 0){const n=Re(t.scaleMargins.top),s=Re(t.scaleMargins.bottom);if(n<0||n>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${n}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(n+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${n+s}`);this.Lo(),this.Co=null}}zo(){return this.yn.autoScale}Oo(){return this.po}ho(){return this.yn.mode===1}je(){return this.yn.mode===2}No(){return this.yn.mode===3}lo(){return this.ko}_e(){return{hs:this.yn.autoScale,Fo:this.yn.invertScale,_e:this.yn.mode}}Ao(t){const n=this._e();let s=null;t.hs!==void 0&&(this.yn.autoScale=t.hs),t._e!==void 0&&(this.yn.mode=t._e,t._e!==2&&t._e!==3||(this.yn.autoScale=!0),this.co.do=!1),n._e===1&&t._e!==n._e&&(function(r,o){if(r===null)return!1;const l=wi(r.Je(),o),c=wi(r.Qe(),o);return isFinite(l)&&isFinite(c)}(this.rr,this.ko)?(s=Ns(this.rr,this.ko),s!==null&&this.Wo(s)):this.yn.autoScale=!0),t._e===1&&t._e!==n._e&&(s=ai(this.rr,this.ko),s!==null&&this.Wo(s));const i=n._e!==this.yn.mode;i&&(n._e===2||this.je())&&this.vl(),i&&(n._e===3||this.No())&&this.vl(),t.Fo!==void 0&&n.Fo!==t.Fo&&(this.yn.invertScale=t.Fo,this.Ho()),this.Mo.p(n,this._e())}Uo(){return this.Mo}P(){return this.Ro.fontSize}$t(){return this.oo}$o(t){this.oo!==t&&(this.oo=t,this.Lo(),this.Co=null)}jo(){if(this._o)return this._o;const t=this.$t()-this.qo()-this.Yo();return this._o=t,t}ar(){return this.Ko(),this.rr}Wo(t,n){const s=this.rr;(n||s===null&&t!==null||s!==null&&!s.Ze(t))&&(this.Co=null,this.rr=t)}Go(t){this.Wo(t),this.Zo(t!==null)}Zi(){return this.Ko(),this.oo===0||!this.rr||this.rr.Zi()}Xo(t){return this.Fo()?t:this.$t()-1-t}Nt(t,n){return this.je()?t=$s(t,n):this.No()&&(t=xi(t,n)),this.Eo(t,n)}Jo(t,n,s){this.Ko();const i=this.Yo(),r=K(this.ar()),o=r.Je(),l=r.Qe(),c=this.jo()-1,h=this.Fo(),a=c/(l-o),u=s===void 0?0:s.from,f=s===void 0?t.length:s.to,p=this.Qo();for(let g=u;g<f;g++){const d=t[g],w=d.Mt;if(isNaN(w))continue;let C=w;p!==null&&(C=p(d.Mt,n));const x=i+a*(C-o),k=h?x:this.oo-1-x;d.ut=k}}t_(t,n,s){this.Ko();const i=this.Yo(),r=K(this.ar()),o=r.Je(),l=r.Qe(),c=this.jo()-1,h=this.Fo(),a=c/(l-o),u=s===void 0?0:s.from,f=s===void 0?t.length:s.to,p=this.Qo();for(let g=u;g<f;g++){const d=t[g];let w=d.jr,C=d.qr,x=d.Yr,k=d.Kr;p!==null&&(w=p(d.jr,n),C=p(d.qr,n),x=p(d.Yr,n),k=p(d.Kr,n));let S=i+a*(w-o),T=h?S:this.oo-1-S;d.i_=T,S=i+a*(C-o),T=h?S:this.oo-1-S,d.n_=T,S=i+a*(x-o),T=h?S:this.oo-1-S,d.s_=T,S=i+a*(k-o),T=h?S:this.oo-1-S,d.e_=T}}Tn(t,n){const s=this.Bo(t,n);return this.r_(s,n)}r_(t,n){let s=t;return this.je()?s=function(i,r){return r<0&&(i=-i),i/100*r+r}(s,n):this.No()&&(s=function(i,r){return i-=100,r<0&&(i=-i),i/100*r+r}(s,n)),s}kl(){return this.bo}Dt(){return this.xo||(this.xo=Xf(this.bo)),this.xo}h_(t){this.bo.indexOf(t)===-1&&(this.bo.push(t),this.vl(),this.a_())}l_(t){const n=this.bo.indexOf(t);if(n===-1)throw new Error("source is not attached to scale");this.bo.splice(n,1),this.bo.length===0&&(this.Ao({hs:!0}),this.Wo(null)),this.vl(),this.a_()}Lt(){let t=null;for(const n of this.bo){const s=n.Lt();s!==null&&(t===null||s.Oa<t.Oa)&&(t=s)}return t===null?null:t.Wt}Fo(){return this.yn.invertScale}zl(){const t=this.Lt()===null;if(this.Co!==null&&(t||this.Co.o_===t))return this.Co.zl;this.Vo.Kl();const n=this.Vo.zl();return this.Co={zl:n,o_:t},this.wo.p(),n}__(){return this.wo}u_(t){this.je()||this.No()||this.yo===null&&this.uo===null&&(this.Zi()||(this.yo=this.oo-t,this.uo=K(this.ar()).Xe()))}c_(t){if(this.je()||this.No()||this.yo===null)return;this.Ao({hs:!1}),(t=this.oo-t)<0&&(t=0);let n=(this.yo+.2*(this.oo-1))/(t+.2*(this.oo-1));const s=K(this.uo).Xe();n=Math.max(n,.1),s.ir(n),this.Wo(s)}d_(){this.je()||this.No()||(this.yo=null,this.uo=null)}f_(t){this.zo()||this.Po===null&&this.uo===null&&(this.Zi()||(this.Po=t,this.uo=K(this.ar()).Xe()))}p_(t){if(this.zo()||this.Po===null)return;const n=K(this.ar()).tr()/(this.jo()-1);let s=t-this.Po;this.Fo()&&(s*=-1);const i=s*n,r=K(this.uo).Xe();r.nr(i),this.Wo(r,!0),this.Co=null}v_(){this.zo()||this.Po!==null&&(this.Po=null,this.uo=null)}sl(){return this.el||this.vl(),this.el}Ji(t,n){switch(this.yn.mode){case 2:return this.m_($s(t,n));case 3:return this.sl().format(xi(t,n));default:return this.cr(t)}}ro(t){switch(this.yn.mode){case 2:return this.m_(t);case 3:return this.sl().format(t);default:return this.cr(t)}}so(t){switch(this.yn.mode){case 2:return this.w_(t);case 3:return this.sl().formatTickmarks(t);default:return this.M_(t)}}xa(t){return this.cr(t,K(this.So).sl())}Ca(t,n){return t=$s(t,n),this.m_(t,Xh)}g_(){return this.bo}b_(t){this.co={fo:t,do:!1}}Nn(){this.bo.forEach(t=>t.Nn())}Xl(){return this.yn.ensureEdgeTickMarksVisible&&this.zo()}Ql(){return this.P()/2}vl(){this.Co=null;let t=1/0;this.So=null;for(const s of this.bo)s.ln()<t&&(t=s.ln(),this.So=s);let n=100;this.So!==null&&(n=Math.round(this.So.Kh())),this.el=Qh,this.je()?(this.el=Xh,n=100):this.No()?(this.el=new Jr(100,1),n=100):this.So!==null&&(this.el=this.So.sl()),this.Vo=new Gh(this,n,this.Bo.bind(this),this.Eo.bind(this)),this.Vo.Kl()}a_(){this.xo=null}S_(){return this.So===null||this.je()||this.No()?1:1/this.So.Kh()}Xi(){return this.Io}Zo(t){this.po=t}qo(){return this.Fo()?this.yn.scaleMargins.bottom*this.$t()+this.mo:this.yn.scaleMargins.top*this.$t()+this.vo}Yo(){return this.Fo()?this.yn.scaleMargins.top*this.$t()+this.vo:this.yn.scaleMargins.bottom*this.$t()+this.mo}Ko(){this.co.do||(this.co.do=!0,this.x_())}Lo(){this._o=null}Eo(t,n){if(this.Ko(),this.Zi())return 0;t=this.ho()&&t?Fr(t,this.ko):t;const s=K(this.ar()),i=this.Yo()+(this.jo()-1)*(t-s.Je())/s.tr();return this.Xo(i)}Bo(t,n){if(this.Ko(),this.Zi())return 0;const s=this.Xo(t),i=K(this.ar()),r=i.Je()+i.tr()*((s-this.Yo())/(this.jo()-1));return this.ho()?wi(r,this.ko):r}Ho(){this.Co=null,this.Vo.Kl()}x_(){if(this.Oo()&&!this.zo())return;const t=this.co.fo;if(t===null)return;let n=null;const s=this.g_();let i=0,r=0;for(const c of s){if(!c.It())continue;const h=c.Lt();if(h===null)continue;const a=c.la(t.Na(),t.bi());let u=a&&a.ar();if(u!==null){switch(this.yn.mode){case 1:u=ai(u,this.ko);break;case 2:u=gx(u,h.Wt);break;case 3:u=yx(u,h.Wt)}if(n=n===null?u:n.Ss(K(u)),a!==null){const f=a.lr();f!==null&&(i=Math.max(i,f.above),r=Math.max(r,f.below))}}}if(this.Xl()&&(i=Math.max(i,this.Ql()),r=Math.max(r,this.Ql())),i===this.vo&&r===this.mo||(this.vo=i,this.mo=r,this.Co=null,this.Lo()),n!==null){if(n.Je()===n.Qe()){const c=5*this.S_();this.ho()&&(n=Ns(n,this.ko)),n=new ke(n.Je()-c,n.Qe()+c),this.ho()&&(n=ai(n,this.ko))}if(this.ho()){const c=Ns(n,this.ko),h=No(c);if(o=h,l=this.ko,o.Ol!==l.Ol||o.Nl!==l.Nl){const a=this.uo!==null?Ns(this.uo,this.ko):null;this.ko=h,n=ai(c,h),a!==null&&(this.uo=ai(a,h))}}this.Wo(n)}else this.rr===null&&(this.Wo(new ke(-.5,.5)),this.ko=No(null));var o,l}Qo(){return this.je()?$s:this.No()?xi:this.ho()?t=>Fr(t,this.ko):null}C_(t,n,s){return n===void 0?(s===void 0&&(s=this.sl()),s.format(t)):n(t)}y_(t,n,s){return n===void 0?(s===void 0&&(s=this.sl()),s.formatTickmarks(t)):n(t)}cr(t,n){return this.C_(t,this.Do.priceFormatter,n)}M_(t,n){const s=this.Do.priceFormatter;return this.y_(t,this.Do.tickmarksPriceFormatter??(s?i=>i.map(s):void 0),n)}m_(t,n){return this.C_(t,this.Do.percentageFormatter,n)}w_(t,n){const s=this.Do.percentageFormatter;return this.y_(t,this.Do.tickmarksPercentageFormatter??(s?i=>i.map(s):void 0),n)}}function Jh(e){return e instanceof Kr}class va{constructor(t,n){this.bo=[],this.P_=new Map,this.oo=0,this.k_=0,this.T_=1,this.xo=null,this.R_=null,this.D_=!1,this.I_=new Zt,this.fa=[],this.ia=t,this.sn=n,this.V_=new px(this);const s=n.N();this.B_=this.E_("left",s.leftPriceScale),this.A_=this.E_("right",s.rightPriceScale),this.B_.Uo().i(this.L_.bind(this,this.B_),this),this.A_.Uo().i(this.L_.bind(this,this.A_),this),this.z_(s)}z_(t){if(t.leftPriceScale&&this.B_.vr(t.leftPriceScale),t.rightPriceScale&&this.A_.vr(t.rightPriceScale),t.localization&&(this.B_.vl(),this.A_.vl()),t.overlayPriceScales){const n=Array.from(this.P_.values());for(const s of n){const i=K(s[0].Ft());i.vr(t.overlayPriceScales),t.localization&&i.vl()}}}O_(t){switch(t){case"left":return this.B_;case"right":return this.A_}return this.P_.has(t)?Re(this.P_.get(t))[0].Ft():null}m(){this.Qt().N_().u(this),this.B_.Uo().u(this),this.A_.Uo().u(this),this.bo.forEach(t=>{t.m&&t.m()}),this.fa=this.fa.filter(t=>{const n=t.Qh();return n.detached&&n.detached(),!1}),this.I_.p()}F_(){return this.T_}W_(t){this.T_=t}Qt(){return this.sn}nn(){return this.k_}$t(){return this.oo}H_(t){this.k_=t,this.U_()}$o(t){this.oo=t,this.B_.$o(t),this.A_.$o(t),this.bo.forEach(n=>{if(this.Gs(n)){const s=n.Ft();s!==null&&s.$o(t)}}),this.U_()}j_(t){this.D_=t}q_(){return this.D_}Y_(){return this.bo.filter(Jh)}kl(){return this.bo}Gs(t){const n=t.Ft();return n===null||this.B_!==n&&this.A_!==n}h_(t,n,s){this.K_(t,n,s?t.ln():this.bo.length)}l_(t,n){const s=this.bo.indexOf(t);pe(s!==-1,"removeDataSource: invalid data source"),this.bo.splice(s,1),n||this.bo.forEach((o,l)=>o._n(l));const i=K(t.Ft()).pl();if(this.P_.has(i)){const o=Re(this.P_.get(i)),l=o.indexOf(t);l!==-1&&(o.splice(l,1),o.length===0&&this.P_.delete(i))}const r=t.Ft();r&&r.kl().indexOf(t)>=0&&(r.l_(t),this.G_(r)),this.Z_()}Xs(t){return t===this.B_?"left":t===this.A_?"right":"overlay"}X_(){return this.B_}J_(){return this.A_}Q_(t,n){t.u_(n)}tu(t,n){t.c_(n),this.U_()}iu(t){t.d_()}nu(t,n){t.f_(n)}su(t,n){t.p_(n),this.U_()}eu(t){t.v_()}U_(){this.bo.forEach(t=>{t.Nn()})}kn(){const[t,n]=this.ru();let s=null;return t.N().visible&&t.kl().length!==0?s=t:n.N().visible&&n.kl().length!==0?s=n:this.bo.length!==0&&(s=this.bo[0].Ft()),s===null&&(s=this.Zs()??t),s}Zs(){const[t,n]=this.ru();return t.N().visible?t:n.N().visible?n:null}G_(t){t!==null&&t.zo()&&this.hu(t)}au(t){const n=this.ia.Ee();t.Ao({hs:!0}),n!==null&&t.b_(n),this.U_()}lu(){this.hu(this.B_),this.hu(this.A_)}ou(){this.G_(this.B_),this.G_(this.A_),this.bo.forEach(t=>{this.Gs(t)&&this.G_(t.Ft())}),this.U_(),this.sn.mr()}Dt(){return this.xo===null&&(this.xo=Xf(this.bo)),this.xo}_u(){var o;const t=this.Dt(),n=(o=this.sn.cu())==null?void 0:o.uu,s=this.sn.N().hoveredSeriesOnTop,i=this.R_;if(i!==null&&i.Kh===t&&i.du===n&&i.fu===s)return i.pu;const r=function(l,c,h){if(!h)return l;const a=l.indexOf(c);if(a===-1||a===l.length-1)return l;const u=[];for(let f=0;f<l.length;f++)f!==a&&u.push(l[f]);return u.push(l[a]),u}(t,n,s);return this.R_={Kh:t,du:n,fu:s,pu:r},r}vu(t,n){n=Ds(n,0,this.bo.length-1);const s=this.bo.indexOf(t);pe(s!==-1,"setSeriesOrder: invalid data source"),this.bo.splice(s,1),this.bo.splice(n,0,t),this.bo.forEach((i,r)=>i._n(r)),this.Z_();for(const i of[this.B_,this.A_])i.a_(),i.vl();this.sn.mr()}Vt(){return this.Dt().filter(Jh)}mu(){return this.I_}wu(){return this.V_}ol(t){this.fa.push(new nx(t))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t),t.detached&&t.detached(),this.sn.mr()}Mu(){return this.fa}il(t,n){return this.fa.map(s=>s.Qs(t,n)).filter(s=>s!==null)}hu(t){const n=t.g_();if(n&&n.length>0&&!this.ia.Zi()){const s=this.ia.Ee();s!==null&&t.b_(s)}t.Nn()}K_(t,n,s){let i=this.O_(n);if(i===null&&(i=this.E_(n,this.sn.N().overlayPriceScales)),this.bo.splice(s,0,t),!Qr(n)){const r=this.P_.get(n)||[];r.push(t),this.P_.set(n,r)}t._n(s),i.h_(t),t.un(i),this.G_(i),this.Z_()}Z_(){this.xo=null,this.R_=null}ru(){return this.sn.N().defaultVisiblePriceScaleId==="left"?[this.B_,this.A_]:[this.A_,this.B_]}L_(t,n,s){n._e!==s._e&&this.hu(t)}E_(t,n){const s={visible:!0,autoScale:!0,...an(n)},i=new bx(t,s,this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return i.$o(this.$t()),i}}function xa(e,t){return t===null||e.se===2&&t.se!==2||(t.se!==2||e.se===2)&&e.ne!==t.ne&&e.ne<t.ne}function Qf(e){return{te:e.te,ie:e.ie}}function vx(e){return{ne:e.distance??0,se:e.hitTestPriority??(e.itemType==="marker"?2:0),ee:e.itemType??"primitive",gu:e.cursorStyle,te:e.externalId}}function ur(e){return{uu:e.uu,bu:Qf(e.Su),gu:e.Su.gu,ee:e.Su.ee??"primitive"}}function xx(e,t,n,s){var r;let i=null;for(const o of e){let l=((r=o.Qs)==null?void 0:r.call(o,t,n,s))??null;if(l===null){const c=o.Tt(s);l=c!==null&&c.Qs?c.Qs(t,n):null}if(l!==null){const c={xu:o,Su:l};(i===null||xa(c.Su,i.Su))&&(i=c)}}return i}function wx(e){return e.jn!==void 0}function Jf(e,t,n){const s=[e,...e.Dt()].reverse(),i=function(l,c,h){var d;let a,u,f;for(const w of l){const C=((d=w.il)==null?void 0:d.call(w,c,h))??[];for(const x of C){const k=vx(x);p=x.zOrder,g=a==null?void 0:a.zOrder,(!g||p==="top"&&g!=="top"||p==="normal"&&g==="bottom"||x.zOrder===(a==null?void 0:a.zOrder)&&u!==void 0&&xa(k,u)||x.zOrder===(a==null?void 0:a.zOrder)&&u===void 0)&&(a=x,u=k,f=w)}}var p,g;return a&&f&&u?{Su:u,Cu:a,uu:f}:null}(s,t,n);if((i==null?void 0:i.Cu.zOrder)==="top")return ur(i);let r=null,o=null;for(const l of s){if(i&&i.uu===l&&i.Cu.zOrder!=="bottom"&&!i.Cu.isBackground)return r??ur(i);if(wx(l)){const c=xx(l.jn(e),t,n,e);if(c!==null){const h={uu:l,xu:c.xu,bu:Qf(c.Su),gu:c.Su.gu,ee:c.Su.ee??"primitive"};(r===null||xa(c.Su,o))&&(r=h,o=c.Su)}}if(i&&i.uu===l&&i.Cu.zOrder!=="bottom"&&i.Cu.isBackground)return r??ur(i)}return r!==null?r:i!=null&&i.Cu?ur(i):null}class Sx{constructor(t,n,s=50){this.Vs=0,this.Bs=1,this.Es=1,this.Ls=new Map,this.As=new Map,this.yu=t,this.Pu=n,this.zs=s}ku(t){const n=t.time,s=this.Pu.cacheKey(n),i=this.Ls.get(s);if(i!==void 0)return i.Tu;if(this.Vs===this.zs){const o=this.As.get(this.Es);this.As.delete(this.Es),this.Ls.delete(Re(o)),this.Es++,this.Vs--}const r=this.yu(t);return this.Ls.set(s,{Tu:r,Ws:this.Bs}),this.As.set(this.Bs,s),this.Vs++,this.Bs++,r}}class Si{constructor(t,n){pe(t<=n,"right should be >= left"),this.Ru=t,this.Du=n}Na(){return this.Ru}bi(){return this.Du}Iu(){return this.Du-this.Ru+1}ze(t){return this.Ru<=t&&t<=this.Du}Ze(t){return this.Ru===t.Na()&&this.Du===t.bi()}}function Kh(e,t){return e===null||t===null?e===t:e.Ze(t)}class Cx{constructor(){this.Vu=new Map,this.Ls=null,this.Bu=!1}Eu(t){this.Bu=t,this.Ls=null}Au(t,n){this.Lu(n),this.Ls=null;for(let s=n;s<t.length;++s){const i=t[s];let r=this.Vu.get(i.timeWeight);r===void 0&&(r=[],this.Vu.set(i.timeWeight,r)),r.push({index:s,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}zu(t,n,s,i,r){const o=Math.ceil(n/t);return this.Ls!==null&&this.Ls.Ou===o&&r===this.Ls.Nu&&s===this.Ls.Fu||(this.Ls={Nu:r,Fu:s,zl:this.Wu(o,s,i),Ou:o}),this.Ls.zl}Lu(t){if(t===0)return void this.Vu.clear();const n=[];this.Vu.forEach((s,i)=>{t<=s[0].index?n.push(i):s.splice(es(s,t,r=>r.index<t),1/0)});for(const s of n)this.Vu.delete(s)}Wu(t,n,s){let i=[];const r=o=>!n||s.has(o.index);for(const o of Array.from(this.Vu.keys()).sort((l,c)=>c-l)){if(!this.Vu.get(o))continue;const l=i;i=[];const c=l.length;let h=0;const a=Re(this.Vu.get(o)),u=a.length;let f=1/0,p=-1/0;for(let g=0;g<u;g++){const d=a[g],w=d.index;for(;h<c;){const C=l[h],x=C.index;if(!(x<w&&r(C))){f=x;break}h++,i.push(C),p=x,f=1/0}if(f-w>=t&&w-p>=t&&r(d))i.push(d),p=w;else if(this.Bu)return l}for(;h<c;h++)r(l[h])&&i.push(l[h])}return i}}class Ls{constructor(t){this.Hu=t}Uu(){return this.Hu===null?null:new Si(Math.floor(this.Hu.Na()),Math.ceil(this.Hu.bi()))}$u(){return this.Hu}static ju(){return new Ls(null)}}function kx(e,t){return e.weight>t.weight?e:t}class Mx{constructor(t,n,s,i){this.k_=0,this.qu=null,this.Yu=[],this.Po=null,this.yo=null,this.Ku=new Cx,this.Gu=new Map,this.Zu=Ls.ju(),this.Xu=!0,this.Ju=new Zt,this.Qu=new Zt,this.tc=new Zt,this.nc=null,this.sc=null,this.ec=new Map,this.rc=-1,this.hc=[],this.ac=1,this.yn=n,this.Do=s,this.lc=n.rightOffset,this.oc=n.barSpacing,this.sn=t,this._c(n),this.Pu=i,this.uc(),this.Ku.Eu(n.uniformDistribution),this.cc(),this.dc()}N(){return this.yn}fc(t){$e(this.Do,t),this.vc(),this.uc()}vr(t,n){$e(this.yn,t),this.yn.fixLeftEdge&&this.mc(),this.yn.fixRightEdge&&this.wc(),t.barSpacing!==void 0&&this.sn.Ms(t.barSpacing),t.rightOffset!==void 0&&this.sn.gs(t.rightOffset),this._c(t),t.minBarSpacing===void 0&&t.maxBarSpacing===void 0||this.sn.Ms(t.barSpacing??this.oc),t.ignoreWhitespaceIndices!==void 0&&t.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this.dc(),this.vc(),this.uc(),t.enableConflation===void 0&&t.conflationThresholdFactor===void 0||this.cc(),this.tc.p()}Rn(t){var n;return((n=this.Yu[t])==null?void 0:n.time)??null}en(t){return this.Yu[t]??null}Mc(t,n){if(this.Yu.length<1)return null;if(this.Pu.key(t)>this.Pu.key(this.Yu[this.Yu.length-1].time))return n?this.Yu.length-1:null;const s=es(this.Yu,this.Pu.key(t),(i,r)=>this.Pu.key(i.time)<r);return this.Pu.key(t)<this.Pu.key(this.Yu[s].time)?n?s:null:s}Zi(){return this.k_===0||this.Yu.length===0||this.qu===null}gc(){return this.Yu.length>0}Ee(){return this.bc(),this.Zu.Uu()}Sc(){return this.bc(),this.Zu.$u()}xc(){const t=this.Ee();if(t===null)return null;const n={from:t.Na(),to:t.bi()};return this.Cc(n)}Cc(t){const n=Math.round(t.from),s=Math.round(t.to),i=K(this.yc()),r=K(this.Pc());return{from:K(this.en(Math.max(i,n))),to:K(this.en(Math.min(r,s)))}}kc(t){return{from:K(this.Mc(t.from,!0)),to:K(this.Mc(t.to,!0))}}nn(){return this.k_}H_(t){if(!isFinite(t)||t<=0||this.k_===t)return;const n=this.Sc(),s=this.k_;if(this.k_=t,this.Xu=!0,this.yn.lockVisibleTimeRangeOnResize&&s!==0){const i=this.oc*t/s;this.oc=i}if(this.yn.fixLeftEdge&&n!==null&&n.Na()<=0){const i=s-t;this.lc-=Math.round(i/this.oc)+1,this.Xu=!0}this.Tc(),this.Rc()}jt(t){if(this.Zi()||!$i(t))return 0;const n=this.Dc()+this.lc-t;return this.k_-(n+.5)*this.oc-1}Ic(t,n){const s=this.Dc(),i=n===void 0?0:n.from,r=n===void 0?t.length:n.to;for(let o=i;o<r;o++){const l=t[o].wt,c=s+this.lc-l,h=this.k_-(c+.5)*this.oc-1;t[o]._t=h}}Vc(t,n){const s=Math.ceil(this.Bc(t));return n&&this.yn.ignoreWhitespaceIndices&&!this.Ec(s)?this.Ac(s):s}gs(t){this.Xu=!0,this.lc=t,this.Rc(),this.sn.Lc(),this.sn.mr()}ml(){return this.oc}Ms(t){const n=this.oc;if(this.zc(t),this.yn.rightOffsetPixels!==void 0&&n!==0){const s=this.lc*n/this.oc;this.lc=s}this.Rc(),this.sn.Lc(),this.sn.mr()}Oc(){return this.lc}zl(){if(this.Zi())return null;if(this.sc!==null)return this.sc;const t=this.oc,n=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),s=Math.round(n/t),i=K(this.Ee()),r=Math.max(i.Na(),i.Na()-s),o=Math.max(i.bi(),i.bi()-s),l=this.Ku.zu(t,n,this.yn.ignoreWhitespaceIndices,this.ec,this.rc),c=this.yc()+s,h=this.Pc()-s,a=this.Nc(),u=this.yn.fixLeftEdge||a,f=this.yn.fixRightEdge||a;let p=0;for(const g of l){if(!(r<=g.index&&g.index<=o))continue;let d;p<this.hc.length?(d=this.hc[p],d.coord=this.jt(g.index),d.label=this.Fc(g),d.weight=g.weight):(d={needAlignCoordinate:!1,coord:this.jt(g.index),label:this.Fc(g),weight:g.weight},this.hc.push(d)),this.oc>n/2&&!a?d.needAlignCoordinate=!1:d.needAlignCoordinate=u&&g.index<=c||f&&g.index>=h,p++}return this.hc.length=p,this.sc=this.hc,this.hc}Wc(){let t;this.Xu=!0,this.Ms(this.yn.barSpacing),t=this.yn.rightOffsetPixels!==void 0?this.yn.rightOffsetPixels/this.ml():this.yn.rightOffset,this.gs(t)}Hc(t){this.Xu=!0,this.qu=t,this.Rc(),this.mc()}Uc(t,n){const s=this.Bc(t),i=this.ml(),r=i+n*(i/10);this.Ms(r),this.yn.rightBarStaysOnScroll||this.gs(this.Oc()+(s-this.Bc(t)))}u_(t){this.Po&&this.v_(),this.yo===null&&this.nc===null&&(this.Zi()||(this.yo=t,this.$c()))}c_(t){if(this.nc===null)return;const n=Ds(this.k_-t,0,this.k_),s=Ds(this.k_-K(this.yo),0,this.k_);n!==0&&s!==0&&this.Ms(this.nc.ml*n/s)}d_(){this.yo!==null&&(this.yo=null,this.jc())}f_(t){this.Po===null&&this.nc===null&&(this.Zi()||(this.Po=t,this.$c()))}p_(t){if(this.Po===null)return;const n=(this.Po-t)/this.ml();this.lc=K(this.nc).Oc+n,this.Xu=!0,this.Rc()}v_(){this.Po!==null&&(this.Po=null,this.jc())}qc(){this.Yc(this.yn.rightOffset)}Yc(t,n=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(n)||n<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.lc,i=performance.now();this.sn.ps({Kc:r=>(r-i)/n>=1,Gc:r=>{const o=(r-i)/n;return o>=1?t:s+(t-s)*o}})}Pt(t,n){this.Xu=!0,this.Yu=t,this.Ku.Au(t,n),this.Rc()}Zc(){return this.Ju}Xc(){return this.Qu}Jc(){return this.tc}Dc(){return this.qu||0}Qc(t,n){const s=t.Iu(),i=n&&this.yn.rightOffsetPixels||0;this.zc((this.k_-i)/s),this.lc=t.bi()-this.Dc(),n&&(this.lc=i?i/this.ml():this.yn.rightOffset),this.Rc(),this.Xu=!0,this.sn.Lc(),this.sn.mr()}td(){const t=this.yc(),n=this.Pc();if(t===null||n===null)return;const s=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Qc(new Si(t,n+s),!0)}nd(t){const n=new Si(t.from,t.to);this.Qc(n)}rn(t){return this.Do.timeFormatter!==void 0?this.Do.timeFormatter(t.originalTime):this.Pu.formatHorzItem(t.time)}dc(){if(!this.yn.ignoreWhitespaceIndices)return;this.ec.clear();const t=this.sn.Jn();for(const n of t)for(const s of n.fl())this.ec.set(s,!0);this.rc++}sd(){return this.ac}Sl(){const t=1/(window.devicePixelRatio||1),n=this.yn.minBarSpacing;if(n>=t)return[1];const s=[1];let i=2;for(;i<=512;)n<t/i&&s.push(i),i*=2;return s}Nc(){const t=this.sn.N().handleScroll,n=this.sn.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||n.axisDoubleClickReset.time||n.axisPressedMouseMove.time||n.mouseWheel||n.pinch)}yc(){return this.Yu.length===0?null:0}Pc(){return this.Yu.length===0?null:this.Yu.length-1}ed(t){return(this.k_-1-t)/this.oc}Bc(t){const n=this.ed(t),s=this.Dc()+this.lc-n;return Math.round(1e6*s)/1e6}zc(t){const n=this.oc;this.oc=t,this.Tc(),n!==this.oc&&(this.Xu=!0,this.rd(),this.cc())}bc(){if(!this.Xu)return;if(this.Xu=!1,this.Zi())return void this.hd(Ls.ju());const t=this.Dc(),n=this.k_/this.oc,s=this.lc+t,i=new Si(s-n+1,s);this.hd(new Ls(i))}Tc(){const t=Ds(this.oc,this.ad(),this.ld());this.oc!==t&&(this.oc=t,this.Xu=!0)}ld(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.k_}ad(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&this.Yu.length!==0?this.k_/this.Yu.length:this.yn.minBarSpacing}cc(){if(!this.yn.enableConflation)return void(this.ac=1);const t=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.oc>=t)return void(this.ac=1);const n=t/this.oc,s=Math.pow(2,Math.floor(Math.log2(n)));this.ac=Math.min(s,512)}Rc(){const t=this.od();t!==null&&this.lc<t&&(this.lc=t,this.Xu=!0);const n=this._d();this.lc>n&&(this.lc=n,this.Xu=!0)}od(){const t=this.yc(),n=this.qu;return t===null||n===null?null:t-n-1+(this.yn.fixLeftEdge?this.k_/this.oc:Math.min(2,this.Yu.length))}_d(){return this.yn.fixRightEdge?0:this.k_/this.oc-Math.min(2,this.Yu.length)}$c(){this.nc={ml:this.ml(),Oc:this.Oc()}}jc(){this.nc=null}Fc(t){let n=this.Gu.get(t.weight);return n===void 0&&(n=new Sx(s=>this.ud(s),this.Pu),this.Gu.set(t.weight,n)),n.ku(t)}ud(t){return this.Pu.formatTickmark(t,this.Do)}hd(t){const n=this.Zu;this.Zu=t,Kh(n.Uu(),this.Zu.Uu())||this.Ju.p(),Kh(n.$u(),this.Zu.$u())||this.Qu.p(),this.rd()}rd(){this.sc=null}vc(){this.rd(),this.Gu.clear()}uc(){this.Pu.updateFormatter(this.Do)}mc(){if(!this.yn.fixLeftEdge)return;const t=this.yc();if(t===null)return;const n=this.Ee();if(n===null)return;const s=n.Na()-t;if(s<0){const i=this.lc-s-1;this.gs(i)}this.Tc()}wc(){this.Rc(),this.Tc()}Ec(t){return!this.yn.ignoreWhitespaceIndices||this.ec.get(t)||!1}Ac(t){const n=function*(i){const r=Math.round(i),o=r<i;let l=1;for(;;)o?(yield r+l,yield r-l):(yield r-l,yield r+l),l++}(t),s=this.Pc();for(;s;){const i=n.next().value;if(this.ec.get(i))return i;if(i<0||i>s)break}return t}_c(t){if(t.rightOffsetPixels!==void 0){const n=t.rightOffsetPixels/(t.barSpacing||this.oc);this.sn.gs(n)}}}var Zh,tu,eu,nu,su;(function(e){e[e.OnTouchEnd=0]="OnTouchEnd",e[e.OnNextTap=1]="OnNextTap"})(Zh||(Zh={}));class Ex{constructor(t,n,s){this.dd=[],this.fd=[],this.pd=null,this.k_=0,this.vd=null,this.md=new Zt,this.wd=new Zt,this.Md=null,this.gd=t,this.yn=n,this.Pu=s,this.Io=new wv(this.yn.layout.colorParsers),this.bd=new xv(this),this.ia=new Mx(this,n.timeScale,this.yn.localization,s),this.Ct=new Nv(this,n.crosshair),this.Sd=new dx(n.crosshair),n.addDefaultPane&&(this.xd(0),this.dd[0].W_(2)),this.Cd=this.yd(0),this.Pd=this.yd(1)}ka(){this.kd(fe.ys())}mr(){this.kd(fe.Cs())}Ya(){this.kd(new fe(1))}Ta(t){const n=this.Td(t);this.kd(n)}cu(){return this.vd}Rd(t){var s,i,r,o,l,c,h,a,u;if(((s=this.vd)==null?void 0:s.uu)===(t==null?void 0:t.uu)&&((r=(i=this.vd)==null?void 0:i.bu)==null?void 0:r.te)===((o=t==null?void 0:t.bu)==null?void 0:o.te)&&((c=(l=this.vd)==null?void 0:l.bu)==null?void 0:c.ie)===((h=t==null?void 0:t.bu)==null?void 0:h.ie)&&((a=this.vd)==null?void 0:a.gu)===(t==null?void 0:t.gu)&&((u=this.vd)==null?void 0:u.ee)===(t==null?void 0:t.ee))return;const n=this.vd;this.vd=t,n!==null&&this.Ta(n.uu),t!==null&&t.uu!==(n==null?void 0:n.uu)&&this.Ta(t.uu)}N(){return this.yn}vr(t){$e(this.yn,t),this.dd.forEach(n=>n.z_(t)),t.timeScale!==void 0&&this.ia.vr(t.timeScale),t.localization!==void 0&&this.ia.fc(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.md.p(),this.Cd=this.yd(0),this.Pd=this.yd(1),this.ka()}Dd(t,n,s=0){const i=this.dd[s];if(i===void 0)return;if(t==="left")return $e(this.yn,{leftPriceScale:n}),i.z_({leftPriceScale:n}),this.md.p(),void this.ka();if(t==="right")return $e(this.yn,{rightPriceScale:n}),i.z_({rightPriceScale:n}),this.md.p(),void this.ka();const r=this.Id(t,s);r!==null&&(r.Ft.vr(n),this.md.p())}Id(t,n){const s=this.dd[n];if(s===void 0)return null;const i=s.O_(t);return i!==null?{Kn:s,Ft:i}:null}Et(){return this.ia}Gn(){return this.dd}Vd(){return this.Ct}Bd(){return this.wd}Ed(t,n){t.$o(n),this.Lc()}H_(t){this.k_=t,this.ia.H_(this.k_),this.dd.forEach(n=>n.H_(t)),this.Lc()}Ad(t){this.dd.length!==1&&(pe(t>=0&&t<this.dd.length,"Invalid pane index"),this.dd.splice(t,1),this.ka())}Ld(t,n){if(this.dd.length<2)return;pe(t>=0&&t<this.dd.length,"Invalid pane index");const s=this.dd[t],i=this.dd.reduce((u,f)=>u+f.F_(),0),r=this.dd.reduce((u,f)=>u+f.$t(),0),o=r-30*(this.dd.length-1);n=Math.min(o,Math.max(30,n));const l=i/r,c=s.$t();s.W_(n*l);let h=n-c,a=this.dd.length-1;for(const u of this.dd)if(u!==s){const f=Math.min(o,Math.max(30,u.$t()-h/a));h-=u.$t()-f,a-=1;const p=f*l;u.W_(p)}this.ka()}zd(t,n){pe(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index");const s=this.dd[t],i=this.dd[n];this.dd[t]=i,this.dd[n]=s,this.ka()}Od(t,n){if(pe(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index"),t===n)return;const[s]=this.dd.splice(t,1);this.dd.splice(n,0,s),this.ka()}Q_(t,n,s){t.Q_(n,s)}tu(t,n,s){t.tu(n,s),this.Ra(),this.kd(this.Nd(t,2))}iu(t,n){t.iu(n),this.kd(this.Nd(t,2))}nu(t,n,s){n.zo()||t.nu(n,s)}su(t,n,s){n.zo()||(t.su(n,s),this.Ra(),this.kd(this.Nd(t,2)))}eu(t,n){n.zo()||(t.eu(n),this.kd(this.Nd(t,2)))}au(t,n){t.au(n),this.kd(this.Nd(t,2))}Fd(t){this.ia.u_(t)}Wd(t,n){const s=this.Et();if(s.Zi()||n===0)return;const i=s.nn();t=Math.max(1,Math.min(t,i)),s.Uc(t,n),this.Lc()}Hd(t){this.Ud(0),this.$d(t),this.jd()}qd(t){this.ia.c_(t),this.Lc()}Yd(){this.ia.d_(),this.mr()}Ud(t){this.ia.f_(t)}$d(t){this.ia.p_(t),this.Lc()}jd(){this.ia.v_(),this.mr()}Jn(){return this.fd}Wn(){return this.pd===null&&(this.pd=this.fd.filter(t=>t.It())),this.pd}Pa(){this.pd=null}Kd(t,n,s,i,r){this.Ct.In(t,n);let o=NaN,l=this.ia.Vc(t,!0);const c=this.ia.Ee();c!==null&&(l=Math.min(Math.max(c.Na(),l),c.bi())),l=this.Ct.Fn(l);const h=i.kn(),a=h.Lt();if(a!==null&&(o=h.Tn(n,a)),o=this.Sd.Pl(o,l,i),this.Ct.An(l,o,i),this.Ya(),!r){const u=Jf(i,t,n);this.Rd(u&&{uu:u.uu,bu:u.bu,gu:u.gu||null,ee:u.ee}),this.wd.p(this.Ct.Bt(),{x:t,y:n},s)}}Gd(t,n,s){const i=s.kn(),r=i.Lt(),o=i.Nt(t,K(r)),l=this.ia.Mc(n,!0),c=this.ia.jt(K(l));this.Kd(c,o,null,s,!0)}Zd(t){this.Vd().zn(),this.Ya(),t||this.wd.p(null,null,null)}Ra(){const t=this.Ct.Kn();if(t!==null){const n=this.Ct.Bn(),s=this.Ct.En();this.Kd(n,s,null,t)}this.Ct.Nn()}Xd(t,n,s){const i=this.ia.Rn(0);n!==void 0&&s!==void 0&&this.ia.Pt(n,s);const r=this.ia.Rn(0),o=this.ia.Dc(),l=this.ia.Ee();if(l!==null&&i!==null&&r!==null){const c=l.ze(o),h=this.Pu.key(i)>this.Pu.key(r),a=t!==null&&t>o&&!h,u=this.ia.N().allowShiftVisibleRangeOnWhitespaceReplacement,f=c&&(s!==void 0||u)&&this.ia.N().shiftVisibleRangeOnNewBar;if(a&&!f){const p=t-o;this.ia.gs(this.ia.Oc()-p)}}this.ia.Hc(t)}Ba(t){t!==null&&t.ou()}Ks(t){if(function(s){return s instanceof va}(t))return t;const n=this.dd.find(s=>s.Dt().includes(t));return n===void 0?null:n}Lc(){this.dd.forEach(t=>t.ou()),this.Ra()}m(){this.dd.forEach(t=>t.m()),this.dd.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Jd(){return this.bd}Js(){return this.bd.N()}N_(){return this.md}Qd(t,n){const s=this.xd(n);this.tf(t,s),this.fd.push(t),this.Pa(),this.fd.length===1?this.ka():this.mr()}if(t){const n=this.Ks(t),s=this.fd.indexOf(t);pe(s!==-1,"Series not found");const i=K(n);this.fd.splice(s,1),i.l_(t),t.m&&t.m(),this.Pa(),this.ia.dc(),this.nf(i)}ya(t,n){const s=K(this.Ks(t));s.l_(t,!0),s.h_(t,n,!0)}td(){const t=fe.Cs();t.us(),this.kd(t)}sf(t){const n=fe.Cs();n.fs(t),this.kd(n)}ws(){const t=fe.Cs();t.ws(),this.kd(t)}Ms(t){const n=fe.Cs();n.Ms(t),this.kd(n)}gs(t){const n=fe.Cs();n.gs(t),this.kd(n)}ps(t){const n=fe.Cs();n.ps(t),this.kd(n)}cs(){const t=fe.Cs();t.cs(),this.kd(t)}ef(){const t=this.yn.defaultVisiblePriceScaleId,n=this.yn.leftPriceScale.visible;return n!==this.yn.rightPriceScale.visible?n?"left":"right":t}rf(t,n){if(pe(n>=0,"Index should be greater or equal to 0"),n===this.hf(t))return;const s=K(this.Ks(t));s.l_(t);const i=this.xd(n);this.tf(t,i);let r=!1;s.kl().length===0&&(r=this.nf(s)),r||this.ka()}af(){return this.Pd}$(){return this.Cd}Ut(t){const n=this.Pd,s=this.Cd;if(n===s)return n;if(t=Math.max(0,Math.min(100,Math.round(100*t))),this.Md===null||this.Md.ah!==s||this.Md.oh!==n)this.Md={ah:s,oh:n,lf:new Map};else{const r=this.Md.lf.get(t);if(r!==void 0)return r}const i=this.Io.tt(s,n,t/100);return this.Md.lf.set(t,i),i}_f(t){return this.dd.indexOf(t)}Xi(){return this.Io}uf(){return this.cf()}cf(t){const n=new va(this.ia,this);this.dd.push(n);const s=t??this.dd.length-1,i=fe.ys();return i.es(s,{rs:0,hs:!0}),this.kd(i),n}xd(t){return pe(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.dd.length,t))<this.dd.length?this.dd[t]:this.cf(t)}hf(t){return this.dd.findIndex(n=>n.Y_().includes(t))}Nd(t,n){const s=new fe(n);if(t!==null){const i=this.dd.indexOf(t);s.es(i,{rs:n})}return s}Td(t,n){return n===void 0&&(n=2),this.Nd(this.Ks(t),n)}kd(t){this.gd&&this.gd(t),this.dd.forEach(n=>n.wu().wr().Pt())}tf(t,n){const s=t.N().priceScaleId,i=s!==void 0?s:this.ef();n.h_(t,i),Qr(i)||t.vr(t.N())}yd(t){const n=this.yn.layout;return n.background.type==="gradient"?t===0?n.background.topColor:n.background.bottomColor:n.background.color}nf(t){return!t.q_()&&t.kl().length===0&&this.dd.length>1&&(this.dd.splice(this._f(t),1),this.ka(),!0)}}function Kf(e){if(e>=1)return 0;let t=0;for(;t<8;t++){const n=Math.round(e);if(Math.abs(n-e)<1e-8)return t;e*=10}return t}function wa(e){return!Ws(e)&&!Bi(e)}function Zf(e){return Ws(e)}(function(e){e[e.Disabled=0]="Disabled",e[e.Continuous=1]="Continuous",e[e.OnDataUpdate=2]="OnDataUpdate"})(tu||(tu={})),function(e){e[e.LastBar=0]="LastBar",e[e.LastVisible=1]="LastVisible"}(eu||(eu={})),function(e){e.Solid="solid",e.VerticalGradient="gradient"}(nu||(nu={})),function(e){e[e.Year=0]="Year",e[e.Month=1]="Month",e[e.DayOfMonth=2]="DayOfMonth",e[e.Time=3]="Time",e[e.TimeWithSeconds=4]="TimeWithSeconds"}(su||(su={}));const iu=e=>e.getUTCFullYear();function Tx(e,t,n){return t.replace(/yyyy/g,(s=>ln(iu(s),4))(e)).replace(/yy/g,(s=>ln(iu(s)%100,2))(e)).replace(/MMMM/g,((s,i)=>new Date(s.getUTCFullYear(),s.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(e,n)).replace(/MMM/g,((s,i)=>new Date(s.getUTCFullYear(),s.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(e,n)).replace(/MM/g,(s=>ln((i=>i.getUTCMonth()+1)(s),2))(e)).replace(/dd/g,(s=>ln((i=>i.getUTCDate())(s),2))(e))}class tm{constructor(t="yyyy-MM-dd",n="default"){this.df=t,this.ff=n}ku(t){return Tx(t,this.df,this.ff)}}class Ax{constructor(t){this.pf=t||"%h:%m:%s"}ku(t){return this.pf.replace("%h",ln(t.getUTCHours(),2)).replace("%m",ln(t.getUTCMinutes(),2)).replace("%s",ln(t.getUTCSeconds(),2))}}const Rx={vf:"yyyy-MM-dd",mf:"%h:%m:%s",wf:" ",Mf:"default"};class Px{constructor(t={}){const n={...Rx,...t};this.gf=new tm(n.vf,n.Mf),this.bf=new Ax(n.mf),this.Sf=n.wf}ku(t){return`${this.gf.ku(t)}${this.Sf}${this.bf.ku(t)}`}}function dr(e){return 60*e*60*1e3}function Do(e){return 60*e*1e3}const fr=[{xf:(ru=1,1e3*ru),Cf:10},{xf:Do(1),Cf:20},{xf:Do(5),Cf:21},{xf:Do(30),Cf:22},{xf:dr(1),Cf:30},{xf:dr(3),Cf:31},{xf:dr(6),Cf:32},{xf:dr(12),Cf:33}];var ru;function ou(e,t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;for(let n=fr.length-1;n>=0;--n)if(Math.floor(t.getTime()/fr[n].xf)!==Math.floor(e.getTime()/fr[n].xf))return fr[n].Cf;return 0}function Lo(e){let t=e;if(Bi(e)&&(t=Sl(e)),!wa(t))throw new Error("time must be of type BusinessDay");const n=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{yf:Math.round(n.getTime()/1e3),Pf:t}}function au(e){if(!Zf(e))throw new Error("time must be of type isUTCTimestamp");return{yf:e}}function Sl(e){const t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid date string=${e}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function lu(e){Bi(e.time)&&(e.time=Sl(e.time))}class cu{options(){return this.yn}setOptions(t){this.yn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(n){n.forEach(lu)}(t):lu(t)}createConverterToInternalObj(t){return K(function(n){return n.length===0?null:wa(n[0].time)||Bi(n[0].time)?Lo:au}(t))}key(t){return typeof t=="object"&&"yf"in t?t.yf:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const n=t;return n.Pf===void 0?new Date(1e3*n.yf).getTime():new Date(Date.UTC(n.Pf.year,n.Pf.month-1,n.Pf.day)).getTime()}convertHorzItemToInternal(t){return Zf(n=t)?au(n):wa(n)?Lo(n):Lo(Sl(n));var n}updateFormatter(t){if(!this.yn)return;const n=t.dateFormat;this.yn.timeScale.timeVisible?this.kf=new Px({vf:n,mf:this.yn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",wf:" ",Mf:t.locale}):this.kf=new tm(n,t.locale)}formatHorzItem(t){const n=t;return this.kf.ku(new Date(1e3*n.yf))}formatTickmark(t,n){const s=function(r,o,l){switch(r){case 0:case 10:return o?l?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return o?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),i=this.yn.timeScale;if(i.tickMarkFormatter!==void 0){const r=i.tickMarkFormatter(t.originalTime,s,n.locale);if(r!==null)return r}return function(r,o,l){const c={};switch(o){case 0:c.year="numeric";break;case 1:c.month="short";break;case 2:c.day="numeric";break;case 3:c.hour12=!1,c.hour="2-digit",c.minute="2-digit";break;case 4:c.hour12=!1,c.hour="2-digit",c.minute="2-digit",c.second="2-digit"}const h=r.Pf===void 0?new Date(1e3*r.yf):new Date(Date.UTC(r.Pf.year,r.Pf.month-1,r.Pf.day));return new Date(h.getUTCFullYear(),h.getUTCMonth(),h.getUTCDate(),h.getUTCHours(),h.getUTCMinutes(),h.getUTCSeconds(),h.getUTCMilliseconds()).toLocaleString(l,c)}(t.time,s,n.locale)}maxTickMarkWeight(t){let n=t.reduce(kx,t[0]).weight;return n>30&&n<50&&(n=30),n}fillWeightsForPoints(t,n){(function(s,i=0){if(s.length===0)return;let r=i===0?null:s[i-1].time.yf,o=r!==null?new Date(1e3*r):null,l=0;for(let c=i;c<s.length;++c){const h=s[c],a=new Date(1e3*h.time.yf);o!==null&&(h.timeWeight=ou(a,o)),l+=h.time.yf-(r||h.time.yf),r=h.time.yf,o=a}if(i===0&&s.length>1){const c=Math.ceil(l/(s.length-1)),h=new Date(1e3*(s[0].time.yf-c));s[0].timeWeight=ou(new Date(1e3*s[0].time.yf),h)}})(t,n)}static Tf(t){return $e({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Vs=typeof window<"u";function hu(){return!!Vs&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function zo(){return!!Vs&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function _x(e,t){switch(e){case"custom":return t!==void 0?"custom-object":"series";case"price-line":return"custom-price-line";case"marker":return"series-marker";case"primitive":return"primitive";default:return"series"}}function Sa(e){return e+e%2}function $x(e){Vs&&window.chrome!==void 0&&e.addEventListener("mousedown",t=>{if(t.button===1)return t.preventDefault(),!1})}class Zr{constructor(t,n,s){this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Af=null,this.Lf=!1,this.zf=null,this.Of=null,this.Nf=!1,this.Ff=!1,this.Wf=!1,this.Hf=null,this.Uf=null,this.$f=null,this.jf=null,this.qf=null,this.Yf=null,this.Kf=null,this.Gf=0,this.Zf=!1,this.Xf=!1,this.Jf=!1,this.Qf=0,this.tp=null,this.ip=!zo(),this.np=i=>{this.sp(i)},this.ep=i=>{if(this.rp(i)){const r=this.hp(i);if(++this.Vf,this.Bf&&this.Vf>1){const{ap:o}=this.lp(Xe(i),this.Ef);o<30&&!this.Wf&&this.op(r,this.up._p),this.cp()}}else{const r=this.hp(i);if(++this.Rf,this.Df&&this.Rf>1){const{ap:o}=this.lp(Xe(i),this.If);o<5&&!this.Ff&&this.dp(r,this.up.fp),this.pp()}}},this.vp=t,this.up=n,this.yn=s,this.mp()}m(){this.Hf!==null&&(this.Hf(),this.Hf=null),this.Uf!==null&&(this.Uf(),this.Uf=null),this.jf!==null&&(this.jf(),this.jf=null),this.qf!==null&&(this.qf(),this.qf=null),this.Yf!==null&&(this.Yf(),this.Yf=null),this.$f!==null&&(this.$f(),this.$f=null),this.wp(),this.pp()}Mp(t){this.jf&&this.jf();const n=this.gp.bind(this);if(this.jf=()=>{this.vp.removeEventListener("mousemove",n)},this.vp.addEventListener("mousemove",n),this.rp(t))return;const s=this.hp(t);this.dp(s,this.up.bp),this.ip=!0}pp(){this.Df!==null&&clearTimeout(this.Df),this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}cp(){this.Bf!==null&&clearTimeout(this.Bf),this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}gp(t){if(this.Jf||this.Of!==null||this.rp(t))return;const n=this.hp(t);this.dp(n,this.up.Sp),this.ip=!0}xp(t){const n=Fo(t.changedTouches,K(this.tp));if(n===null||(this.Qf=mr(t),this.Kf!==null)||this.Xf)return;this.Zf=!0;const s=this.lp(Xe(n),K(this.Of)),{Cp:i,yp:r,ap:o}=s;if(this.Nf||!(o<5)){if(!this.Nf){const l=.5*i,c=r>=l&&!this.yn.Pp(),h=l>r&&!this.yn.kp();c||h||(this.Xf=!0),this.Nf=!0,this.Wf=!0,this.wp(),this.cp()}if(!this.Xf){const l=this.hp(t,n);this.op(l,this.up.Tp),ks(t)}}}Rp(t){if(t.button!==0)return;const n=this.lp(Xe(t),K(this.zf)),{ap:s}=n;if(s>=5&&(this.Ff=!0,this.pp()),this.Ff){const i=this.hp(t);this.dp(i,this.up.Dp)}}lp(t,n){const s=Math.abs(n._t-t._t),i=Math.abs(n.ut-t.ut);return{Cp:s,yp:i,ap:s+i}}Ip(t){let n=Fo(t.changedTouches,K(this.tp));if(n===null&&t.touches.length===0&&(n=t.changedTouches[0]),n===null)return;this.tp=null,this.Qf=mr(t),this.wp(),this.Of=null,this.Yf&&(this.Yf(),this.Yf=null);const s=this.hp(t,n);if(this.op(s,this.up.Vp),++this.Vf,this.Bf&&this.Vf>1){const{ap:i}=this.lp(Xe(n),this.Ef);i<30&&!this.Wf&&this.op(s,this.up._p),this.cp()}else this.Wf||(this.op(s,this.up.Bp),this.up.Bp&&ks(t));this.Vf===0&&ks(t),t.touches.length===0&&this.Lf&&(this.Lf=!1,ks(t))}sp(t){if(t.button!==0)return;const n=this.hp(t);if(this.zf=null,this.Jf=!1,this.qf&&(this.qf(),this.qf=null),hu()&&this.vp.ownerDocument.documentElement.removeEventListener("mouseleave",this.np),!this.rp(t))if(this.dp(n,this.up.Ep),++this.Rf,this.Df&&this.Rf>1){const{ap:s}=this.lp(Xe(t),this.If);s<5&&!this.Ff&&this.dp(n,this.up.fp),this.pp()}else this.Ff||this.dp(n,this.up.Ap)}wp(){this.Af!==null&&(clearTimeout(this.Af),this.Af=null)}Lp(t){if(this.tp!==null)return;const n=t.changedTouches[0];this.tp=n.identifier,this.Qf=mr(t);const s=this.vp.ownerDocument.documentElement;this.Wf=!1,this.Nf=!1,this.Xf=!1,this.Of=Xe(n),this.Yf&&(this.Yf(),this.Yf=null);{const r=this.xp.bind(this),o=this.Ip.bind(this);this.Yf=()=>{s.removeEventListener("touchmove",r),s.removeEventListener("touchend",o)},s.addEventListener("touchmove",r,{passive:!1}),s.addEventListener("touchend",o,{passive:!1}),this.wp(),this.Af=setTimeout(this.zp.bind(this,t),240)}const i=this.hp(t,n);this.op(i,this.up.Op),this.Bf||(this.Vf=0,this.Bf=setTimeout(this.cp.bind(this),500),this.Ef=Xe(n))}Np(t){if(t.button!==0)return;const n=this.vp.ownerDocument.documentElement;hu()&&n.addEventListener("mouseleave",this.np),this.Ff=!1,this.zf=Xe(t),this.qf&&(this.qf(),this.qf=null);{const i=this.Rp.bind(this),r=this.sp.bind(this);this.qf=()=>{n.removeEventListener("mousemove",i),n.removeEventListener("mouseup",r)},n.addEventListener("mousemove",i),n.addEventListener("mouseup",r)}if(this.Jf=!0,this.rp(t))return;const s=this.hp(t);this.dp(s,this.up.Fp),this.Df||(this.Rf=0,this.Df=setTimeout(this.pp.bind(this),500),this.If=Xe(t))}mp(){this.vp.addEventListener("mouseenter",this.Mp.bind(this)),this.vp.addEventListener("touchcancel",this.wp.bind(this));{const t=this.vp.ownerDocument,n=s=>{this.up.Wp&&(s.composed&&this.vp.contains(s.composedPath()[0])||s.target&&this.vp.contains(s.target)||this.up.Wp())};this.Uf=()=>{t.removeEventListener("touchstart",n)},this.Hf=()=>{t.removeEventListener("mousedown",n)},t.addEventListener("mousedown",n),t.addEventListener("touchstart",n,{passive:!0})}zo()&&(this.$f=()=>{this.vp.removeEventListener("dblclick",this.ep)},this.vp.addEventListener("dblclick",this.ep)),this.vp.addEventListener("mouseleave",this.Hp.bind(this)),this.vp.addEventListener("touchstart",this.Lp.bind(this),{passive:!0}),$x(this.vp),this.vp.addEventListener("mousedown",this.Np.bind(this)),this.Up(),this.vp.addEventListener("touchmove",()=>{},{passive:!1})}Up(){this.up.$p===void 0&&this.up.jp===void 0&&this.up.qp===void 0||(this.vp.addEventListener("touchstart",t=>this.Yp(t.touches),{passive:!0}),this.vp.addEventListener("touchmove",t=>{if(t.touches.length===2&&this.Kf!==null&&this.up.jp!==void 0){const n=uu(t.touches[0],t.touches[1])/this.Gf;this.up.jp(this.Kf,n),ks(t)}},{passive:!1}),this.vp.addEventListener("touchend",t=>{this.Yp(t.touches)}))}Yp(t){t.length===1&&(this.Zf=!1),t.length!==2||this.Zf||this.Lf?this.Kp():this.Gp(t)}Gp(t){const n=this.vp.getBoundingClientRect()||{left:0,top:0};this.Kf={_t:(t[0].clientX-n.left+(t[1].clientX-n.left))/2,ut:(t[0].clientY-n.top+(t[1].clientY-n.top))/2},this.Gf=uu(t[0],t[1]),this.up.$p!==void 0&&this.up.$p(),this.wp()}Kp(){this.Kf!==null&&(this.Kf=null,this.up.qp!==void 0&&this.up.qp())}Hp(t){if(this.jf&&this.jf(),this.rp(t)||!this.ip)return;const n=this.hp(t);this.dp(n,this.up.Zp),this.ip=!zo()}zp(t){const n=Fo(t.touches,K(this.tp));if(n===null)return;const s=this.hp(t,n);this.op(s,this.up.Xp),this.Wf=!0,this.Lf=!0}rp(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents!==void 0?t.sourceCapabilities.firesTouchEvents:mr(t)<this.Qf+500}op(t,n){n&&n.call(this.up,t)}dp(t,n){n&&n.call(this.up,t)}hp(t,n){const s=n||t,i=this.vp.getBoundingClientRect()||{left:0,top:0};return{clientX:s.clientX,clientY:s.clientY,pageX:s.pageX,pageY:s.pageY,screenX:s.screenX,screenY:s.screenY,localX:s.clientX-i.left,localY:s.clientY-i.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Jp:!t.type.startsWith("mouse")&&t.type!=="contextmenu"&&t.type!=="click",Qp:t.type,tv:s.target,xu:t.view,iv:()=>{t.type!=="touchstart"&&ks(t)}}}}function uu(e,t){const n=e.clientX-t.clientX,s=e.clientY-t.clientY;return Math.sqrt(n*n+s*s)}function ks(e){e.cancelable&&e.preventDefault()}function Xe(e){return{_t:e.pageX,ut:e.pageY}}function mr(e){return e.timeStamp||performance.now()}function Fo(e,t){for(let n=0;n<e.length;++n)if(e[n].identifier===t)return e[n];return null}class Nx{constructor(t,n,s){this.nv=null,this.sv=null,this.ev=!0,this.rv=null,this.hv=t,this.av=t.lv()[n],this.ov=t.lv()[s],this._v=document.createElement("tr"),this._v.style.height="1px",this.uv=document.createElement("td"),this.uv.style.position="relative",this.uv.style.padding="0",this.uv.style.margin="0",this.uv.setAttribute("colspan","3"),this.cv(),this._v.appendChild(this.uv),this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv=null,this.sv=null)}m(){this.sv!==null&&this.sv.m()}fv(){return this._v}pv(){return Nt({width:this.av.pv().width,height:1})}vv(){return Nt({width:this.av.vv().width,height:1*window.devicePixelRatio})}mv(t,n,s){const i=this.vv();t.fillStyle=this.hv.N().layout.panes.separatorColor,t.fillRect(n,s,i.width,i.height)}Pt(){this.cv(),this.hv.N().layout.panes.enableResize!==this.ev&&(this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv!==null&&(this.uv.removeChild(this.nv.wv),this.uv.removeChild(this.nv.Mv),this.nv=null),this.sv!==null&&(this.sv.m(),this.sv=null)))}dv(){const t=document.createElement("div"),n=t.style;n.position="fixed",n.display="none",n.zIndex="49",n.top="0",n.left="0",n.width="100%",n.height="100%",n.cursor="row-resize",this.uv.appendChild(t);const s=document.createElement("div"),i=s.style;i.position="absolute",i.zIndex="50",i.top="-4px",i.height="9px",i.width="100%",i.backgroundColor="",i.cursor="row-resize",this.uv.appendChild(s);const r={bp:this.gv.bind(this),Zp:this.bv.bind(this),Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this)};this.sv=new Zr(s,r,{Pp:()=>!1,kp:()=>!0}),this.nv={Mv:s,wv:t}}cv(){this.uv.style.background=this.hv.N().layout.panes.separatorColor}gv(t){this.nv!==null&&(this.nv.Mv.style.backgroundColor=this.hv.N().layout.panes.separatorHoverColor)}bv(t){this.nv!==null&&this.rv===null&&(this.nv.Mv.style.backgroundColor="")}Sv(t){if(this.nv===null)return;const n=this.av.yv().F_()+this.ov.yv().F_(),s=n/(this.av.pv().height+this.ov.pv().height),i=30*s;n<=2*i||(this.rv={Pv:t.pageY,kv:this.av.yv().F_(),Tv:n-i,Rv:n,Dv:s,Iv:i},this.nv.wv.style.display="block")}xv(t){const n=this.rv;if(n===null)return;const s=(t.pageY-n.Pv)*n.Dv,i=Ds(n.kv+s,n.Iv,n.Tv);this.av.yv().W_(i),this.ov.yv().W_(n.Rv-i),this.hv.Qt().ka()}Cv(t){this.rv!==null&&this.nv!==null&&(this.rv=null,this.nv.wv.style.display="none")}}function Bo(e,t){return e.Vv-t.Vv}function Wo(e,t,n){const s=(e.Vv-t.Vv)/(e.wt-t.wt);return Math.sign(s)*Math.min(Math.abs(s),n)}class Ix{constructor(t,n,s,i){this.Bv=null,this.Ev=null,this.Av=null,this.Lv=null,this.zv=null,this.Ov=0,this.Nv=0,this.Fv=t,this.Wv=n,this.Hv=s,this.Ps=i}Uv(t,n){if(this.Bv!==null){if(this.Bv.wt===n)return void(this.Bv.Vv=t);if(Math.abs(this.Bv.Vv-t)<this.Ps)return}this.Lv=this.Av,this.Av=this.Ev,this.Ev=this.Bv,this.Bv={wt:n,Vv:t}}me(t,n){if(this.Bv===null||this.Ev===null||n-this.Bv.wt>50)return;let s=0;const i=Wo(this.Bv,this.Ev,this.Wv),r=Bo(this.Bv,this.Ev),o=[i],l=[r];if(s+=r,this.Av!==null){const h=Wo(this.Ev,this.Av,this.Wv);if(Math.sign(h)===Math.sign(i)){const a=Bo(this.Ev,this.Av);if(o.push(h),l.push(a),s+=a,this.Lv!==null){const u=Wo(this.Av,this.Lv,this.Wv);if(Math.sign(u)===Math.sign(i)){const f=Bo(this.Av,this.Lv);o.push(u),l.push(f),s+=f}}}}let c=0;for(let h=0;h<o.length;++h)c+=l[h]/s*o[h];Math.abs(c)<this.Fv||(this.zv={Vv:t,wt:n},this.Nv=c,this.Ov=function(h,a){const u=Math.log(a);return Math.log(1*u/-h)/u}(Math.abs(c),this.Hv))}Gc(t){const n=K(this.zv),s=t-n.wt;return n.Vv+this.Nv*(Math.pow(this.Hv,s)-1)/Math.log(this.Hv)}Kc(t){return this.zv===null||this.$v(t)===this.Ov}$v(t){const n=t-K(this.zv).wt;return Math.min(n,this.Ov)}}class Dx{constructor(t,n){this.jv=void 0,this.qv=void 0,this.Yv=void 0,this.vn=!1,this.Kv=t,this.Gv=n,this.Zv()}Pt(){this.Zv()}Xv(){this.jv&&this.Kv.removeChild(this.jv),this.qv&&this.Kv.removeChild(this.qv),this.jv=void 0,this.qv=void 0}Jv(){return this.vn!==this.Qv()||this.Yv!==this.tm()}tm(){return this.Gv.Qt().Xi().J(this.Gv.N().layout.textColor)>160?"dark":"light"}Qv(){return this.Gv.N().layout.attributionLogo}im(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Zv(){this.Jv()&&(this.Xv(),this.vn=this.Qv(),this.vn&&(this.Yv=this.tm(),this.qv=document.createElement("style"),this.qv.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.jv=document.createElement("a"),this.jv.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.im()}`,this.jv.title="Charting by TradingView",this.jv.id="tv-attr-logo",this.jv.target="_blank",this.jv.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.jv.toggleAttribute("data-dark",this.Yv==="dark"),this.Kv.appendChild(this.qv),this.Kv.appendChild(this.jv)))}}function ns(e,t){const n=K(e.ownerDocument).createElement("canvas");e.appendChild(n);const s=gv(n,{options:{allowResizeObserver:!0},transform:(i,r)=>({width:Math.max(i.width,r.width),height:Math.max(i.height,r.height)})});return s.resizeCanvasElement(t),s}function ss(e){var t;e.width=1,e.height=1,(t=e.getContext("2d"))==null||t.clearRect(0,0,1,1)}function xr(e,t,n,s){e.qh&&e.qh(t,n,s)}function fi(e,t,n,s){e.st(t,n,s)}function Ca(e,t,n,s){em(e(n,s),t,s)}function em(e,t,n){for(const s of e){const i=s.Tt(n);i!==null&&t(i)}}function Vo(e,t){return n=>{var s,i;return function(r){return r.Ft!==void 0}(n)?(((s=n.Ft())==null?void 0:s.pl())??"")!==t?[]:((i=n.Qa)==null?void 0:i.call(n,e))??[]:[]}}function du(e,t,n,s){if(!e.length)return;let i=0;const r=e[0].$t(s,!0);let o=t===1?n/2-(e[0].Hi()-r/2):e[0].Hi()-r/2-n/2;o=Math.max(0,o);for(let l=1;l<e.length;l++){const c=e[l],h=e[l-1],a=h.$t(s,!1),u=c.Hi(),f=h.Hi();if(t===1?u>f-a:u<f+a){const p=f-a*t;c.Ui(p);const g=p-t*a/2;if((t===1?g<0:g>n)&&o>0){const d=t===1?-1-g:g-n,w=Math.min(d,o);for(let C=i;C<e.length;C++)e[C].Ui(e[C].Hi()+t*w);o-=w}}else i=l,o=t===1?f-a-u:u-(f+a)}}class fu{constructor(t,n,s,i){this.Ki=null,this.nm=null,this.sm=!1,this.rm=new Dr(200),this.hm=null,this.am=0,this.lm=!1,this.om=()=>{this.lm||this.yt._m().Qt().mr()},this.um=()=>{this.lm||this.yt._m().Qt().mr()},this.yt=t,this.yn=n,this.Ro=n.layout,this.bd=s,this.dm=i==="left",this.fm=Vo("normal",i),this.pm=Vo("top",i),this.vm=Vo("bottom",i),this.uv=document.createElement("div"),this.uv.style.height="100%",this.uv.style.overflow="hidden",this.uv.style.width="25px",this.uv.style.left="0",this.uv.style.position="relative",this.wm=ns(this.uv,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const r=this.wm.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.Mm=ns(this.uv,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const o=this.Mm.canvasElement;o.style.position="absolute",o.style.zIndex="2",o.style.left="0",o.style.top="0";const l={Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Wp:this.gm.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this),fp:this.bm.bind(this),_p:this.bm.bind(this),bp:this.Sm.bind(this),Zp:this.bv.bind(this)};this.sv=new Zr(this.Mm.canvasElement,l,{Pp:()=>!this.yn.handleScroll.vertTouchDrag,kp:()=>!0})}m(){this.sv.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose(),this.Ki!==null&&this.Ki.__().u(this),this.Ki=null}fv(){return this.uv}P(){return this.Ro.fontSize}xm(){const t=this.bd.N();return this.hm!==t.k&&(this.rm.Os(),this.hm=t.k),t}Cm(){if(this.Ki===null)return 0;let t=0;const n=this.xm(),s=K(this.wm.canvasElement.getContext("2d",{colorSpace:this.yt._m().N().layout.colorSpace}));s.save();const i=this.Ki.zl();s.font=this.ym(),i.length>0&&(t=Math.max(this.rm.Ii(s,i[0].eo),this.rm.Ii(s,i[i.length-1].eo)));const r=this.Pm();for(let h=r.length;h--;){const a=this.rm.Ii(s,r[h].ri());a>t&&(t=a)}const o=this.Ki.Lt();if(o!==null&&this.nm!==null&&(l=this.yn.crosshair).mode!==2&&l.horzLine.visible&&l.horzLine.labelVisible){const h=this.Ki.Tn(1,o),a=this.Ki.Tn(this.nm.height-2,o);t=Math.max(t,this.rm.Ii(s,this.Ki.Ji(Math.floor(Math.min(h,a))+.11111111111111,o)),this.rm.Ii(s,this.Ki.Ji(Math.ceil(Math.max(h,a))-.11111111111111,o)))}var l;s.restore();const c=t||34;return Sa(Math.ceil(n.S+n.C+n.V+n.B+5+c))}km(t){this.nm!==null&&Kn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`)}Tm(){return K(this.nm).width}un(t){this.Ki!==t&&(this.Ki!==null&&this.Ki.__().u(this),this.Ki=t,t.__().i(this.wo.bind(this),this))}Ft(){return this.Ki}Os(){const t=this.yt.yv();this.yt._m().Qt().au(t,K(this.Ft()))}Rm(t){if(this.nm===null)return;const n={colorSpace:this.yt._m().N().layout.colorSpace};if(t!==1){this.Dm(),this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r),this.Vm(r)}),this.yt.Bm(i,this.vm),this.Em(i),this.yt.Bm(i,this.fm),this.Am(i))}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Lm(s),this.yt.Bm(s,this.pm))}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t.drawImage(o,n,s)}}Pt(){var t;(t=this.Ki)==null||t.zl()}Sv(t){if(this.Ki===null||this.Ki.Zi()||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv();this.sm=!0,n.Q_(s,this.Ki,t.localY)}xv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv(),i=this.Ki;n.tu(s,i,t.localY)}gm(){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const t=this.yt._m().Qt(),n=this.yt.yv(),s=this.Ki;this.sm&&(this.sm=!1,t.iu(n,s))}Cv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv();this.sm=!1,n.iu(s,this.Ki)}bm(t){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}Sm(t){this.Ki!==null&&(!this.yt._m().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.je()||this.Ki.No()||this.zm(1))}bv(t){this.zm(0)}Pm(){const t=[],n=this.Ki===null?void 0:this.Ki;return(s=>{for(let i=0;i<s.length;++i){const r=s[i].qn(this.yt.yv(),n);for(let o=0;o<r.length;o++)t.push(r[o])}})(this.yt.yv().Dt()),t}Im({context:t,bitmapSize:n}){const{width:s,height:i}=n,r=this.yt.yv().Qt(),o=r.$(),l=r.af();o===l?Yr(t,0,0,s,i,o):Wf(t,0,0,s,i,o,l)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:s}){if(this.nm===null||this.Ki===null||!this.Ki.N().borderVisible)return;t.fillStyle=this.Ki.N().borderColor;const i=Math.max(1,Math.floor(this.xm().S*s));let r;r=this.dm?n.width-i:0,t.fillRect(r,0,i,n.height)}Em(t){if(this.nm===null||this.Ki===null)return;const n=this.Ki.zl(),s=this.Ki.N(),i=this.xm(),r=this.dm?this.nm.width-i.C:0;s.borderVisible&&s.ticksVisible&&t.useBitmapCoordinateSpace(({context:o,horizontalPixelRatio:l,verticalPixelRatio:c})=>{o.fillStyle=s.borderColor;const h=Math.max(1,Math.floor(c)),a=Math.floor(.5*c),u=Math.round(i.C*l);o.beginPath();for(const f of n)o.rect(Math.floor(r*l),Math.round(f.Vl*c)-a,u,h);o.fill()}),t.useMediaCoordinateSpace(({context:o})=>{o.font=this.ym(),o.fillStyle=s.textColor??this.Ro.textColor,o.textAlign=this.dm?"right":"left",o.textBaseline="middle";const l=this.dm?Math.round(r-i.V):Math.round(r+i.C+i.V),c=n.map(h=>this.rm.Di(o,h.eo));for(let h=n.length;h--;){const a=n[h];o.fillText(a.eo,l,a.Vl+c[h])}})}Dm(){if(this.nm===null||this.Ki===null)return;let t=this.nm.height/2;const n=[],s=this.Ki.Dt().slice(),i=this.yt.yv(),r=this.xm();this.Ki===i.Zs()&&this.yt.yv().Dt().forEach(c=>{i.Gs(c)&&s.push(c)});const o=this.Ki.kl()[0],l=this.Ki;s.forEach(c=>{const h=c.qn(i,l);h.forEach(a=>{a.$i()&&a.Wi()===null&&(a.Ui(null),n.push(a))}),o===c&&h.length>0&&(t=h[0].Ei())}),this.Ki.N().alignLabels&&this.Om(n,r,t)}Om(t,n,s){if(this.nm===null)return;const i=t.filter(o=>o.Ei()<=s),r=t.filter(o=>o.Ei()>s);i.sort((o,l)=>l.Ei()-o.Ei()),i.length&&r.length&&r.push(i[0]),r.sort((o,l)=>o.Ei()-l.Ei());for(const o of t){const l=Math.floor(o.$t(n)/2),c=o.Ei();c>-l&&c<l&&o.Ui(l),c>this.nm.height-l&&c<this.nm.height+l&&o.Ui(this.nm.height-l)}du(i,1,this.nm.height,n),du(r,-1,this.nm.height,n)}Am(t){if(this.nm===null)return;const n=this.Pm(),s=this.xm(),i=this.dm?"right":"left";n.forEach(r=>{r.ji()&&r.Tt(K(this.Ki)).st(t,s,this.rm,i)})}Lm(t){if(this.nm===null||this.Ki===null)return;const n=this.yt._m().Qt(),s=[],i=this.yt.yv(),r=n.Vd().qn(i,this.Ki);r.length&&s.push(r);const o=this.xm(),l=this.dm?"right":"left";s.forEach(c=>{c.forEach(h=>{h.Tt(K(this.Ki)).st(t,o,this.rm,l)})})}zm(t){this.uv.style.cursor=t===1?"ns-resize":"default"}wo(){const t=this.Cm();this.am<t&&this.yt._m().Qt().ka(),this.am=t}ym(){return Ir(this.Ro.fontSize,this.Ro.fontFamily)}}function Lx(e,t){var n;return((n=e.Xa)==null?void 0:n.call(e,t))??[]}function jo(e,t){var n;return((n=e.jn)==null?void 0:n.call(e,t))??[]}function mu(e,t){var n;return((n=e.cn)==null?void 0:n.call(e,t))??[]}function zx(e,t){var n;return((n=e.qa)==null?void 0:n.call(e,t))??[]}class Cl{constructor(t,n){this.nm=Nt({width:0,height:0}),this.Nm=null,this.Fm=null,this.Wm=null,this.Hm=null,this.Um=!1,this.$m=new Zt,this.jm=new Zt,this.qm=0,this.Ym=!1,this.Km=null,this.Gm=!1,this.Zm=null,this.Xm=null,this.lm=!1,this.om=()=>{this.lm||this.Jm===null||this.sn().mr()},this.um=()=>{this.lm||this.Jm===null||this.sn().mr()},this.Gv=t,this.Jm=n,this.Jm.mu().i(this.Qm.bind(this),this,!0),this.tw=document.createElement("td"),this.tw.style.padding="0",this.tw.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.iw=document.createElement("td"),this.iw.style.padding="0",this.nw=document.createElement("td"),this.nw.style.padding="0",this.tw.appendChild(s),this.wm=ns(s,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const i=this.wm.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Mm=ns(s,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const r=this.Mm.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0",this._v=document.createElement("tr"),this._v.appendChild(this.iw),this._v.appendChild(this.tw),this._v.appendChild(this.nw),this.sw(),this.sv=new Zr(this.Mm.canvasElement,this,{Pp:()=>this.Km===null&&!this.Gv.N().handleScroll.vertTouchDrag,kp:()=>this.Km===null&&!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.Nm!==null&&this.Nm.m(),this.Fm!==null&&this.Fm.m(),this.Wm=null,this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose(),this.Jm!==null&&(this.Jm.mu().u(this),this.Jm.m()),this.sv.m()}yv(){return K(this.Jm)}ew(t){var n;this.Jm!==null&&this.Jm.mu().u(this),this.Jm=t,this.Jm!==null&&this.Jm.mu().i(Cl.prototype.Qm.bind(this),this,!0),this.sw(),this.Gv.lv().indexOf(this)===this.Gv.lv().length-1?(this.Wm=this.Wm??new Dx(this.tw,this.Gv),this.Wm.Pt()):((n=this.Wm)==null||n.Xv(),this.Wm=null)}_m(){return this.Gv}fv(){return this._v}sw(){if(this.Jm!==null&&(this.rw(),this.sn().Jn().length!==0)){if(this.Nm!==null){const t=this.Jm.X_();this.Nm.un(K(t))}if(this.Fm!==null){const t=this.Jm.J_();this.Fm.un(K(t))}}}hw(){this.Nm!==null&&this.Nm.Pt(),this.Fm!==null&&this.Fm.Pt()}F_(){return this.Jm!==null?this.Jm.F_():0}W_(t){this.Jm&&this.Jm.W_(t)}bp(t){if(!this.Jm)return;this.aw();const n=t.localX,s=t.localY;this.lw(n,s,t)}Fp(t){this.aw(),this.ow(),this.lw(t.localX,t.localY,t)}Sp(t){if(!this.Jm)return;this.aw();const n=t.localX,s=t.localY;this.lw(n,s,t)}Ap(t){this.Jm!==null&&(this.aw(),this.lw(t.localX,t.localY,t),this._w(t))}fp(t){this.Jm!==null&&this.uw(this.jm,t)}_p(t){this.fp(t)}Dp(t){this.aw(),this.cw(t),this.lw(t.localX,t.localY,t)}Ep(t){this.Jm!==null&&(this.aw(),this.Ym=!1,this.dw(t))}Bp(t){this.Jm!==null&&this._w(t)}Xp(t){if(this.Ym=!0,this.Km===null){const n={x:t.localX,y:t.localY};this.fw(n,n,t)}}Zp(t){this.Jm!==null&&(this.aw(),this.Jm.Qt().Rd(null),this.pw())}mw(){return this.$m}ww(){return this.jm}$p(){this.qm=1,this.sn().cs()}jp(t,n){if(!this.Gv.N().handleScale.pinch)return;const s=5*(n-this.qm);this.qm=n,this.sn().Wd(t._t,s)}Op(t){this.Ym=!1,this.Gm=this.Km!==null,this.ow();const n=this.sn().Vd();this.Km!==null&&n.It()&&(this.Zm={x:n.ni(),y:n.si()},this.Km={x:t.localX,y:t.localY})}Tp(t){if(this.Jm===null)return;const n=t.localX,s=t.localY;if(this.Km===null)this.cw(t);else{this.Gm=!1;const i=K(this.Zm),r=i.x+(n-this.Km.x),o=i.y+(s-this.Km.y);this.lw(r,o,t)}}Vp(t){this._m().N().trackingMode.exitMode===0&&(this.Gm=!0),this.Mw(),this.dw(t)}Qs(t,n){const s=this.Jm;return s===null?null:Jf(s,t,n)}gw(t,n){K(n==="left"?this.Nm:this.Fm).km(Nt({width:t,height:this.nm.height}))}pv(){return this.nm}km(t){Kn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.tw.style.width=t.width+"px",this.tw.style.height=t.height+"px")}bw(){const t=K(this.Jm);t.G_(t.X_()),t.G_(t.J_());for(const n of t.kl())if(t.Gs(n)){const s=n.Ft();s!==null&&t.G_(s),n.Nn()}for(const n of t.Mu())n.Nn()}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t!==null&&t.drawImage(o,n,s)}}Rm(t){if(t===0||this.Jm===null)return;t>1&&this.bw(),this.Nm!==null&&this.Nm.Rm(t),this.Fm!==null&&this.Fm.Rm(t);const n={colorSpace:this.Gv.N().layout.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r)}),this.Jm&&(this.Sw(i,Lx),this.xw(i),this.Sw(i,jo),this.Sw(i,mu)))}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Cw(s),this.Sw(s,zx),this.Sw(s,mu))}yw(){return this.Nm}Pw(){return this.Fm}Bm(t,n){this.Sw(t,n)}Qm(){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=null}_w(t){this.uw(this.$m,t)}uw(t,n){const s=n.localX,i=n.localY;t.v()&&t.p(this.sn().Et().Vc(s),{x:s,y:i},n)}Im({context:t,bitmapSize:n}){const{width:s,height:i}=n,r=this.sn(),o=r.$(),l=r.af();o===l?Yr(t,0,0,s,i,l):Wf(t,0,0,s,i,o,l)}xw(t){const n=K(this.Jm),s=n.wu().wr().Tt(n);s!==null&&s.st(t,!1)}Cw(t){this.kw(t,jo,fi,this.sn().Vd())}Sw(t,n){const s=K(this.Jm),i=n===jo?this.Tw():null,r=i===null?null:this.Rw(i,s),o=s.Mu();if(r===null||i===null){const h=s._u();return this.Dw(t,n,xr,o,h),void this.Dw(t,n,fi,o,h)}const l=s.Dt(),c=h=>h===i?r.Za:void 0;this.Dw(t,n,xr,o,l,c),this.Dw(t,n,fi,o,l,c),this.kw(t,n,xr,i,r.qa),this.kw(t,n,fi,i,r.qa)}Dw(t,n,s,i,r,o){for(const l of i)this.kw(t,n,s,l);if(o!==void 0)for(const l of r)this.kw(t,n,s,l,o(l));else for(const l of r)this.kw(t,n,s,l)}Tw(){var s;const t=K(this.Jm),n=(s=t.Qt().cu())==null?void 0:s.uu;if(!t.Qt().N().hoveredSeriesOnTop||n===void 0)return null;for(const i of t.Dt())if(i===n)return i;return null}Rw(t,n){var i;const s=((i=t.Ga)==null?void 0:i.call(t,n))??null;return s===null||s.qa.length===0?null:s}kw(t,n,s,i,r){const o=K(this.Jm),l=o.Qt().cu(),c=l!==null&&l.uu===i,h=l!==null&&c&&l.bu!==void 0?l.bu.ie:void 0,a=u=>s(u,t,c,h);r===void 0?Ca(n,a,i,o):em(r,a,o)}rw(){if(this.Jm===null)return;const t=this.Gv,n=this.Jm.X_().N().visible,s=this.Jm.J_().N().visible;n||this.Nm===null||(this.iw.removeChild(this.Nm.fv()),this.Nm.m(),this.Nm=null),s||this.Fm===null||(this.nw.removeChild(this.Fm.fv()),this.Fm.m(),this.Fm=null);const i=t.Qt().Jd();n&&this.Nm===null&&(this.Nm=new fu(this,t.N(),i,"left"),this.iw.appendChild(this.Nm.fv())),s&&this.Fm===null&&(this.Fm=new fu(this,t.N(),i,"right"),this.nw.appendChild(this.Fm.fv()))}Iw(t){return t.Jp&&this.Ym||this.Km!==null}lw(t,n,s){t=Math.max(0,Math.min(t,this.nm.width-1)),n=Math.max(0,Math.min(n,this.nm.height-1)),this.sn().Kd(t,n,s,K(this.Jm))}pw(){this.sn().Zd()}Mw(){this.Gm&&(this.Km=null,this.pw())}fw(t,n,s){this.Km=t,this.Gm=!1,this.lw(n.x,n.y,s);const i=this.sn().Vd();this.Zm={x:i.ni(),y:i.si()}}sn(){return this.Gv.Qt()}dw(t){if(!this.Um)return;const n=this.sn(),s=this.yv();if(n.eu(s,s.kn()),this.Hm=null,this.Um=!1,n.jd(),this.Xm!==null){const i=performance.now(),r=n.Et();this.Xm.me(r.Oc(),i),this.Xm.Kc(i)||n.ps(this.Xm)}}aw(){this.Km=null}ow(){if(this.Jm){if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)K(document.activeElement).blur();else{const t=document.getSelection();t!==null&&t.removeAllRanges()}!this.Jm.kn().Zi()&&this.sn().Et().Zi()}}cw(t){if(this.Jm===null)return;const n=this.sn(),s=n.Et();if(s.Zi())return;const i=this.Gv.N(),r=i.handleScroll,o=i.kineticScroll;if((!r.pressedMouseMove||t.Jp)&&(!r.horzTouchDrag&&!r.vertTouchDrag||!t.Jp))return;const l=this.Jm.kn(),c=performance.now();if(this.Hm!==null||this.Iw(t)||(this.Hm={x:t.clientX,y:t.clientY,yf:c,Vw:t.localX,Bw:t.localY}),this.Hm!==null&&!this.Um&&(this.Hm.x!==t.clientX||this.Hm.y!==t.clientY)){if(t.Jp&&o.touch||!t.Jp&&o.mouse){const h=s.ml();this.Xm=new Ix(.2/h,7/h,.997,15/h),this.Xm.Uv(s.Oc(),this.Hm.yf)}else this.Xm=null;l.Zi()||n.nu(this.Jm,l,t.localY),n.Ud(t.localX),this.Um=!0}this.Um&&(l.Zi()||n.su(this.Jm,l,t.localY),n.$d(t.localX),this.Xm!==null&&this.Xm.Uv(s.Oc(),c))}}class pu{constructor(t,n,s,i,r){this.xt=!0,this.nm=Nt({width:0,height:0}),this.om=()=>this.Rm(3),this.dm=t==="left",this.bd=s.Jd,this.yn=n,this.Ew=i,this.Aw=r,this.uv=document.createElement("div"),this.uv.style.width="25px",this.uv.style.height="100%",this.uv.style.overflow="hidden",this.wm=ns(this.uv,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om)}m(){this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose()}fv(){return this.uv}pv(){return this.nm}km(t){Kn(this.nm,t)||(this.nm=t,this.wm.resizeCanvasElement(t),this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.xt=!0)}Rm(t){if(t<3&&!this.xt||this.nm.width===0||this.nm.height===0)return;this.xt=!1,this.wm.applySuggestedBitmapSize();const n=ts(this.wm,{colorSpace:this.yn.layout.colorSpace});n!==null&&n.useBitmapCoordinateSpace(s=>{this.Im(s),this.Vm(s)})}vv(){return this.wm.bitmapSize}mv(t,n,s){const i=this.vv();i.width>0&&i.height>0&&t.drawImage(this.wm.canvasElement,n,s)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(!this.Ew())return;t.fillStyle=this.yn.timeScale.borderColor;const r=Math.floor(this.bd.N().S*s),o=Math.floor(this.bd.N().S*i),l=this.dm?n.width-r:0;t.fillRect(l,0,r,o)}Im({context:t,bitmapSize:n}){Yr(t,0,0,n.width,n.height,this.Aw())}}function kl(e){return t=>{var n;return((n=t.tl)==null?void 0:n.call(t,e))??[]}}const Fx=kl("normal"),Bx=kl("top"),Wx=kl("bottom");class Vx{constructor(t,n){this.Lw=null,this.zw=null,this.M=null,this.Ow=!1,this.nm=Nt({width:0,height:0}),this.Nw=new Zt,this.rm=new Dr(5),this.lm=!1,this.om=()=>{this.lm||this.Gv.Qt().mr()},this.um=()=>{this.lm||this.Gv.Qt().mr()},this.Gv=t,this.Pu=n,this.yn=t.N().layout,this.jv=document.createElement("tr"),this.Fw=document.createElement("td"),this.Fw.style.padding="0",this.Ww=document.createElement("td"),this.Ww.style.padding="0",this.uv=document.createElement("td"),this.uv.style.height="25px",this.uv.style.padding="0",this.Hw=document.createElement("div"),this.Hw.style.width="100%",this.Hw.style.height="100%",this.Hw.style.position="relative",this.Hw.style.overflow="hidden",this.uv.appendChild(this.Hw),this.wm=ns(this.Hw,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const s=this.wm.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Mm=ns(this.Hw,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const i=this.Mm.canvasElement;i.style.position="absolute",i.style.zIndex="2",i.style.left="0",i.style.top="0",this.jv.appendChild(this.Fw),this.jv.appendChild(this.uv),this.jv.appendChild(this.Ww),this.Uw(),this.Gv.Qt().N_().i(this.Uw.bind(this),this),this.sv=new Zr(this.Mm.canvasElement,this,{Pp:()=>!0,kp:()=>!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.sv.m(),this.Lw!==null&&this.Lw.m(),this.zw!==null&&this.zw.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose()}fv(){return this.jv}$w(){return this.Lw}jw(){return this.zw}Fp(t){if(this.Ow)return;this.Ow=!0;const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.Fd(t.localX)}Op(t){this.Fp(t)}Wp(){const t=this.Gv.Qt();!t.Et().Zi()&&this.Ow&&(this.Ow=!1,this.Gv.N().handleScale.axisPressedMouseMove.time&&t.Yd())}Dp(t){const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.qd(t.localX)}Tp(t){this.Dp(t)}Ep(){this.Ow=!1;const t=this.Gv.Qt();t.Et().Zi()&&!this.Gv.N().handleScale.axisPressedMouseMove.time||t.Yd()}Vp(){this.Ep()}fp(){this.Gv.N().handleScale.axisDoubleClickReset.time&&this.Gv.Qt().ws()}_p(){this.fp()}bp(){this.Gv.Qt().N().handleScale.axisPressedMouseMove.time&&this.zm(1)}Zp(){this.zm(0)}pv(){return this.nm}qw(){return this.Nw}Yw(t,n,s){Kn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.Nw.p(t)),this.Lw!==null&&this.Lw.km(Nt({width:n,height:t.height})),this.zw!==null&&this.zw.km(Nt({width:s,height:t.height}))}Kw(){const t=this.Gw();return Math.ceil(t.S+t.C+t.P+t.A+t.I+t.Zw)}Pt(){this.Gv.Qt().Et().zl()}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t.drawImage(o,n,s)}}Rm(t){if(t===0)return;const n={colorSpace:this.yn.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r),this.Vm(r),this.Xw(i,Wx)}),this.Em(i),this.Xw(i,Fx)),this.Lw!==null&&this.Lw.Rm(t),this.zw!==null&&this.zw.Rm(t)}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Jw([...this.Gv.Qt().Jn(),this.Gv.Qt().Vd()],s),this.Xw(s,Bx))}Xw(t,n){const s=this.Gv.Qt().Jn();for(const i of s)Ca(n,r=>xr(r,t,!1,void 0),i,void 0);for(const i of s)Ca(n,r=>fi(r,t,!1,void 0),i,void 0)}Im({context:t,bitmapSize:n}){Yr(t,0,0,n.width,n.height,this.Gv.Qt().af())}Vm({context:t,bitmapSize:n,verticalPixelRatio:s}){if(this.Gv.N().timeScale.borderVisible){t.fillStyle=this.Qw();const i=Math.max(1,Math.floor(this.Gw().S*s));t.fillRect(0,0,n.width,i)}}Em(t){const n=this.Gv.Qt().Et(),s=n.zl();if(!s||s.length===0)return;const i=this.Pu.maxTickMarkWeight(s),r=this.Gw(),o=n.N();o.borderVisible&&o.ticksVisible&&t.useBitmapCoordinateSpace(({context:l,horizontalPixelRatio:c,verticalPixelRatio:h})=>{l.strokeStyle=this.Qw(),l.fillStyle=this.Qw();const a=Math.max(1,Math.floor(c)),u=Math.floor(.5*c);l.beginPath();const f=Math.round(r.C*h);for(let p=s.length;p--;){const g=Math.round(s[p].coord*c);l.rect(g-u,0,a,f)}l.fill()}),t.useMediaCoordinateSpace(({context:l})=>{const c=r.S+r.C+r.A+r.P/2;l.textAlign="center",l.textBaseline="middle",l.fillStyle=this.H(),l.font=this.ym();for(const h of s)if(h.weight<i){const a=h.needAlignCoordinate?this.tM(l,h.coord,h.label):h.coord;l.fillText(h.label,a,c)}this.Gv.N().timeScale.allowBoldLabels&&(l.font=this.iM());for(const h of s)if(h.weight>=i){const a=h.needAlignCoordinate?this.tM(l,h.coord,h.label):h.coord;l.fillText(h.label,a,c)}})}tM(t,n,s){const i=this.rm.Ii(t,s),r=i/2,o=Math.floor(n-r)+.5;return o<0?n+=Math.abs(0-o):o+i>this.nm.width&&(n-=Math.abs(this.nm.width-(o+i))),n}Jw(t,n){const s=this.Gw();for(const i of t)for(const r of i.dn())r.Tt().st(n,s)}Qw(){return this.Gv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}ym(){return Ir(this.F(),this.yn.fontFamily)}iM(){return Ir(this.F(),this.yn.fontFamily,"bold")}Gw(){this.M===null&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,P:NaN,k:"",Qi:new Dr,Zw:0});const t=this.M,n=this.ym();if(t.k!==n){const s=this.F();t.P=s,t.k=n,t.A=3*s/12,t.I=3*s/12,t.tn=9*s/12,t.L=0,t.Zw=4*s/12,t.Qi.Os()}return this.M}zm(t){this.uv.style.cursor=t===1?"ew-resize":"default"}Uw(){const t=this.Gv.Qt(),n=t.N();n.leftPriceScale.visible||this.Lw===null||(this.Fw.removeChild(this.Lw.fv()),this.Lw.m(),this.Lw=null),n.rightPriceScale.visible||this.zw===null||(this.Ww.removeChild(this.zw.fv()),this.zw.m(),this.zw=null);const s={Jd:this.Gv.Qt().Jd()},i=()=>n.leftPriceScale.borderVisible&&t.Et().N().borderVisible,r=()=>t.af();n.leftPriceScale.visible&&this.Lw===null&&(this.Lw=new pu("left",n,s,i,r),this.Fw.appendChild(this.Lw.fv())),n.rightPriceScale.visible&&this.zw===null&&(this.zw=new pu("right",n,s,i,r),this.Ww.appendChild(this.zw.fv()))}}var Bu;const jx=!!Vs&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(e=>e.brand.includes("Chromium"))&&!!Vs&&((Bu=navigator==null?void 0:navigator.userAgentData)!=null&&Bu.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);class Ox{constructor(t,n,s){var i;this.nM=[],this.sM=[],this.eM=0,this.oo=0,this.k_=0,this.rM=0,this.hM=0,this.aM=null,this.lM=!1,this.$m=new Zt,this.jm=new Zt,this.wd=new Zt,this.oM=null,this._M=null,this.Kv=t,this.yn=n,this.Pu=s,this.jv=document.createElement("div"),this.jv.classList.add("tv-lightweight-charts"),this.jv.style.overflow="hidden",this.jv.style.direction="ltr",this.jv.style.width="100%",this.jv.style.height="100%",(i=this.jv).style.userSelect="none",i.style.webkitUserSelect="none",i.style.msUserSelect="none",i.style.MozUserSelect="none",i.style.webkitTapHighlightColor="transparent",this.uM=document.createElement("table"),this.uM.setAttribute("cellspacing","0"),this.jv.appendChild(this.uM),this.cM=this.dM.bind(this),Oo(this.yn)&&this.fM(!0),this.sn=new Ex(this.gd.bind(this),this.yn,s),this.Qt().Bd().i(this.pM.bind(this),this),this.vM=new Vx(this,this.Pu),this.uM.appendChild(this.vM.fv());const r=n.autoSize&&this.mM();let o=this.yn.width,l=this.yn.height;if(r||o===0||l===0){const c=t.getBoundingClientRect();o=o||c.width,l=l||c.height}this.wM(o,l),this.MM(),t.appendChild(this.jv),this.gM(),this.sn.Et().Jc().i(this.sn.ka.bind(this.sn),this),this.sn.N_().i(this.sn.ka.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}lv(){return this.nM}bM(){return this.vM}m(){this.fM(!1),this.eM!==0&&window.cancelAnimationFrame(this.eM),this.sn.Bd().u(this),this.sn.Et().Jc().u(this),this.sn.N_().u(this),this.sn.m();for(const t of this.nM)this.uM.removeChild(t.fv()),t.mw().u(this),t.ww().u(this),t.m();this.nM=[];for(const t of this.sM)this.SM(t);this.sM=[],K(this.vM).m(),this.jv.parentElement!==null&&this.jv.parentElement.removeChild(this.jv),this.wd.m(),this.$m.m(),this.jm.m(),this.xM()}wM(t,n,s=!1){if(this.oo===n&&this.k_===t)return;const i=function(l){const c=Math.floor(l.width),h=Math.floor(l.height);return Nt({width:c-c%2,height:h-h%2})}(Nt({width:t,height:n}));this.oo=i.height,this.k_=i.width;const r=this.oo+"px",o=this.k_+"px";if(this.CM()||(K(this.jv).style.height=r,K(this.jv).style.width=o),this.uM.style.height=r,this.uM.style.width=o,s){this.eM!==0&&(window.cancelAnimationFrame(this.eM),this.eM=0),this.lM=!1;const l=fe.ys();this.aM!==null&&(l.Ss(this.aM),this.aM=null),this.yM(l,performance.now())}else this.sn.ka()}Rm(t){t===void 0&&(t=fe.ys());for(let n=0;n<this.nM.length;n++)this.nM[n].Rm(t._s(n).rs);this.yn.timeScale.visible&&this.vM.Rm(t.ls())}vr(t){var i;const n=Oo(this.yn);this.sn.vr(t);const s=Oo(this.yn);s!==n&&this.fM(s),(i=t.layout)!=null&&i.panes&&this.PM(),this.gM(),this.kM(t)}mw(){return this.$m}ww(){return this.jm}Bd(){return this.wd}TM(t=!1){this.aM!==null&&(this.yM(this.aM,performance.now()),this.aM=null);const n=this.RM(null),s=document.createElement("canvas");s.width=n.width,s.height=n.height;const i=K(s.getContext("2d"));return this.RM(i,t),s}DM(t){return t==="left"&&!this.IM()||t==="right"&&!this.VM()||this.nM.length===0?0:K(t==="left"?this.nM[0].yw():this.nM[0].Pw()).Tm()}CM(){return this.yn.autoSize&&this.oM!==null}Mv(){return this.jv}BM(t){this._M=t,this._M?this.Mv().style.setProperty("cursor",t):this.Mv().style.removeProperty("cursor")}EM(){return this._M}AM(t){return Re(this.nM[t]).pv()}PM(){this.sM.forEach(t=>{t.Pt()})}kM(t){(t.autoSize!==void 0||!this.oM||t.width===void 0&&t.height===void 0)&&(t.autoSize&&!this.oM&&this.mM(),t.autoSize===!1&&this.oM!==null&&this.xM(),t.autoSize||t.width===void 0&&t.height===void 0||this.wM(t.width||this.k_,t.height||this.oo))}RM(t,n){let s=0,i=0;const r=this.nM[0],o=(c,h)=>{let a=0;for(let u=0;u<this.nM.length;u++){const f=this.nM[u],p=K(c==="left"?f.yw():f.Pw()),g=p.vv();if(t!==null&&p.mv(t,h,a,n),a+=g.height,u<this.nM.length-1){const d=this.sM[u],w=d.vv();t!==null&&d.mv(t,h,a),a+=w.height}}};this.IM()&&(o("left",0),s+=K(r.yw()).vv().width);for(let c=0;c<this.nM.length;c++){const h=this.nM[c],a=h.vv();if(t!==null&&h.mv(t,s,i,n),i+=a.height,c<this.nM.length-1){const u=this.sM[c],f=u.vv();t!==null&&u.mv(t,s,i),i+=f.height}}s+=r.vv().width,this.VM()&&(o("right",s),s+=K(r.Pw()).vv().width);const l=(c,h,a)=>{K(c==="left"?this.vM.$w():this.vM.jw()).mv(K(t),h,a)};if(this.yn.timeScale.visible){const c=this.vM.vv();if(t!==null){let h=0;this.IM()&&(l("left",h,i),h=K(r.yw()).vv().width),this.vM.mv(t,h,i,n),h+=c.width,this.VM()&&l("right",h,i)}i+=c.height}return Nt({width:s,height:i})}LM(){let t=0,n=0,s=0;for(const w of this.nM)this.IM()&&(n=Math.max(n,K(w.yw()).Cm(),this.yn.leftPriceScale.minimumWidth)),this.VM()&&(s=Math.max(s,K(w.Pw()).Cm(),this.yn.rightPriceScale.minimumWidth)),t+=w.F_();n=Sa(n),s=Sa(s);const i=this.k_,r=this.oo,o=Math.max(i-n-s,0),l=1*this.sM.length,c=this.yn.timeScale.visible;let h=c?Math.max(this.vM.Kw(),this.yn.timeScale.minimumHeight):0;var a;h=(a=h)+a%2;const u=l+h,f=r<u?0:r-u,p=f/t;let g=0;const d=window.devicePixelRatio||1;for(let w=0;w<this.nM.length;++w){const C=this.nM[w];C.ew(this.sn.Gn()[w]);let x=0,k=0;k=w===this.nM.length-1?Math.ceil((f-g)*d)/d:Math.round(C.F_()*p*d)/d,x=Math.max(k,2),g+=x,C.km(Nt({width:o,height:x})),this.IM()&&C.gw(n,"left"),this.VM()&&C.gw(s,"right"),C.yv()&&this.sn.Ed(C.yv(),x)}this.vM.Yw(Nt({width:c?o:0,height:h}),c?n:0,c?s:0),this.sn.H_(o),this.rM!==n&&(this.rM=n),this.hM!==s&&(this.hM=s)}fM(t){t?this.jv.addEventListener("wheel",this.cM,{passive:!1}):this.jv.removeEventListener("wheel",this.cM)}zM(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return jx?1/window.devicePixelRatio:1}dM(t){if(!(t.deltaX!==0&&this.yn.handleScroll.mouseWheel||t.deltaY!==0&&this.yn.handleScale.mouseWheel))return;const n=this.zM(t),s=n*t.deltaX/100,i=-n*t.deltaY/100;if(t.cancelable&&t.preventDefault(),i!==0&&this.yn.handleScale.mouseWheel){const r=Math.sign(i)*Math.min(1,Math.abs(i)),o=t.clientX-this.jv.getBoundingClientRect().left;this.Qt().Wd(o,r)}s!==0&&this.yn.handleScroll.mouseWheel&&this.Qt().Hd(-80*s)}yM(t,n){var i;const s=t.ls();s===3&&this.OM(),s!==3&&s!==2||(this.NM(t),this.FM(t,n),this.vM.Pt(),this.nM.forEach(r=>{r.hw()}),((i=this.aM)==null?void 0:i.ls())===3&&(this.aM.Ss(t),this.OM(),this.NM(this.aM),this.FM(this.aM,n),t=this.aM,this.aM=null)),this.Rm(t)}FM(t,n){for(const s of t.bs())this.xs(s,n)}NM(t){const n=this.sn.Gn();for(let s=0;s<n.length;s++)t._s(s).hs&&n[s].lu()}xs(t,n){const s=this.sn.Et();switch(t.ds){case 0:s.td();break;case 1:s.nd(t.Wt);break;case 2:s.Ms(t.Wt);break;case 3:s.gs(t.Wt);break;case 4:s.Wc();break;case 5:t.Wt.Kc(n)||s.gs(t.Wt.Gc(n))}}gd(t){this.aM!==null?this.aM.Ss(t):this.aM=t,this.lM||(this.lM=!0,this.eM=window.requestAnimationFrame(n=>{if(this.lM=!1,this.eM=0,this.aM!==null){const s=this.aM;this.aM=null,this.yM(s,n);for(const i of s.bs())if(i.ds===5&&!i.Wt.Kc(n)){this.Qt().ps(i.Wt);break}}}))}OM(){this.MM()}SM(t){this.uM.removeChild(t.fv()),t.m()}MM(){const t=this.sn.Gn(),n=t.length,s=this.nM.length;for(let i=n;i<s;i++){const r=Re(this.nM.pop());this.uM.removeChild(r.fv()),r.mw().u(this),r.ww().u(this),r.m();const o=this.sM.pop();o!==void 0&&this.SM(o)}for(let i=s;i<n;i++){const r=new Cl(this,t[i]);if(r.mw().i(this.WM.bind(this,r),this),r.ww().i(this.HM.bind(this,r),this),this.nM.push(r),i>0){const o=new Nx(this,i-1,i);this.sM.push(o),this.uM.insertBefore(o.fv(),this.vM.fv())}this.uM.insertBefore(r.fv(),this.vM.fv())}for(let i=0;i<n;i++){const r=t[i],o=this.nM[i];o.yv()!==r?o.ew(r):o.sw()}this.gM(),this.LM()}UM(t,n,s,i){var a;const r=new Map;t!==null&&this.sn.Jn().forEach(u=>{const f=u.Un().Hn(t);f!==null&&r.set(u,f)});let o;if(t!==null){const u=(a=this.sn.Et().en(t))==null?void 0:a.originalTime;u!==void 0&&(o=u)}const l=this.Qt().cu(),c=this.$M(i),h=function(u,f){var x;const p=u!==null&&u.uu instanceof Kr?u.uu:void 0,g=(x=u==null?void 0:u.bu)==null?void 0:x.te,d=f!==void 0&&f!==-1?f:void 0;return u===null||u.ee===void 0?{jM:p,qM:g}:{jM:p,qM:g,YM:{ds:u.ee,KM:(w=u.uu,C=u.ee,w instanceof va?"pane-primitive":C==="marker"||C==="primitive"?"series-primitive":"series"),GM:_x(u.ee,g),Y_:p,ZM:g,XM:d}};var w,C}(l,c);return{Qr:o,$n:t??void 0,JM:n??void 0,XM:c!==-1?c:void 0,jM:h.jM,QM:r,qM:h.qM,YM:h.YM,tg:s??void 0}}$M(t){let n=-1;if(t)n=this.nM.indexOf(t);else{const s=this.Qt().Vd().Kn();s!==null&&(n=this.Qt().Gn().indexOf(s))}return n}WM(t,n,s,i){this.$m.p(()=>this.UM(n,s,i,t))}HM(t,n,s,i){this.jm.p(()=>this.UM(n,s,i,t))}pM(t,n,s){var i;this.BM(((i=this.Qt().cu())==null?void 0:i.gu)??null),this.wd.p(()=>this.UM(t,n,s))}gM(){const t=this.yn.timeScale.visible?"":"none";this.vM.fv().style.display=t}IM(){return this.nM[0].yv().X_().N().visible}VM(){return this.nM[0].yv().J_().N().visible}mM(){return"ResizeObserver"in window&&(this.oM=new ResizeObserver(t=>{const n=t[t.length-1];if(!n)return;const s=n.contentRect.width,i=n.contentRect.height;this.wM(s,i,!0)}),this.oM.observe(this.Kv,{box:"border-box"}),!0)}xM(){this.oM!==null&&this.oM.disconnect(),this.oM=null}}function Oo(e){return!!(e.handleScroll.mouseWheel||e.handleScale.mouseWheel)}function Ux(e){return e.open===void 0&&e.value===void 0}function Hx(e){return function(t){return t.open!==void 0}(e)||function(t){return t.value!==void 0}(e)}function gu(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.color!==void 0&&(r.R=n.color),r}function qx(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.lineColor!==void 0&&(r.vt=n.lineColor),n.topColor!==void 0&&(r.ah=n.topColor),n.bottomColor!==void 0&&(r.oh=n.bottomColor),r}function Gx(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.topLineColor!==void 0&&(r._h=n.topLineColor),n.bottomLineColor!==void 0&&(r.uh=n.bottomLineColor),n.topFillColor1!==void 0&&(r.dh=n.topFillColor1),n.topFillColor2!==void 0&&(r.fh=n.topFillColor2),n.bottomFillColor1!==void 0&&(r.ph=n.bottomFillColor1),n.bottomFillColor2!==void 0&&(r.mh=n.bottomFillColor2),r}function Yx(e,t,n,s){const i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:s};return n.color!==void 0&&(i.R=n.color),i}function Xx(e,t,n,s){const i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:s};return n.color!==void 0&&(i.R=n.color),n.borderColor!==void 0&&(i.Ht=n.borderColor),n.wickColor!==void 0&&(i.hh=n.wickColor),i}function Qx(e,t,n,s,i){const r=Re(i)(n),o=Math.max(...r),l=Math.min(...r),c=r[r.length-1],h=[c,o,l,c],{time:a,color:u,...f}=n;return{$n:t,wt:e,Wt:h,Qr:s,ue:f,R:u}}function Ms(e){return e.Wt!==void 0}function yu(e,t){return t.customValues!==void 0&&(e.ig=t.customValues),e}function qn(e){return(t,n,s,i,r,o)=>function(l,c){return c?c(l):Ux(l)}(s,o)?yu({wt:t,$n:n,Qr:i},s):yu(e(t,n,s,i,r),s)}function bu(e){return{Candlestick:qn(Xx),Bar:qn(Yx),Area:qn(qx),Baseline:qn(Gx),Histogram:qn(gu),Line:qn(gu),Custom:qn(Qx)}[e]}function vu(e){return{$n:0,ng:new Map,Oa:e}}function xu(e,t){if(e!==void 0&&e.length!==0)return{sg:t.key(e[0].wt),eg:t.key(e[e.length-1].wt)}}function wu(e){let t;return e.forEach(n=>{t===void 0&&(t=n.Qr)}),Re(t)}class Jx{constructor(t){this.rg=new Map,this.hg=new Map,this.ag=new Map,this.lg=[],this.Pu=t}m(){this.rg.clear(),this.hg.clear(),this.ag.clear(),this.lg=[]}og(t,n){let s=this.rg.size!==0,i=!1;const r=this.hg.get(t);if(r!==void 0)if(this.hg.size===1)s=!1,i=!0,this.rg.clear();else for(const c of this.lg)c.pointData.ng.delete(t)&&(i=!0);let o=[];if(n.length!==0){const c=n.map(p=>p.time),h=this.Pu.createConverterToInternalObj(n),a=bu(t.bh()),u=t.ul(),f=t.cl();o=n.map((p,g)=>{const d=h(p.time),w=this.Pu.key(d);let C=this.rg.get(w);C===void 0&&(C=vu(d),this.rg.set(w,C),i=!0);const x=a(d,C.$n,p,c[g],u,f);return C.ng.set(t,x),x})}s&&this._g(),this.ug(t,o);let l=-1;if(i){const c=[];this.rg.forEach(h=>{c.push({timeWeight:0,time:h.Oa,pointData:h,originalTime:wu(h.ng)})}),c.sort((h,a)=>this.Pu.key(h.time)-this.Pu.key(a.time)),l=this.cg(c)}return this.dg(t,l,function(c,h,a){const u=xu(c,a),f=xu(h,a);if(u!==void 0&&f!==void 0)return{fg:!1,Va:u.eg>=f.eg&&u.sg>=f.sg}}(this.hg.get(t),r,this.Pu))}if(t){return this.og(t,[])}pg(t,n,s){if(s&&t.Fa())throw new Error("Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.");const i=n;(function(C){C.Qr===void 0&&(C.Qr=C.time)})(i),this.Pu.preprocessData(n);const r=this.Pu.createConverterToInternalObj([n])(n.time),o=this.ag.get(t);if(!s&&o!==void 0&&this.Pu.key(r)<this.Pu.key(o))throw new Error(`Cannot update oldest data, last time=${o}, new time=${r}`);let l=this.rg.get(this.Pu.key(r));if(s&&l===void 0)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const c=l===void 0;l===void 0&&(l=vu(r),this.rg.set(this.Pu.key(r),l));const h=bu(t.bh()),a=t.ul(),u=t.cl(),f=h(r,l.$n,n,i.Qr,a,u),p=!s&&!c&&o!==void 0&&this.Pu.key(r)===this.Pu.key(o);l.ng.set(t,f),s?this.vg(t,f,l.$n):p&&t.Fa()&&Ms(f)?(t.Rr(f),this.mg(t,f)):this.mg(t,f);const g={Va:Ms(f),fg:s};if(!c)return this.dg(t,-1,g);const d={timeWeight:0,time:l.Oa,pointData:l,originalTime:wu(l.ng)},w=es(this.lg,this.Pu.key(d.time),(C,x)=>this.Pu.key(C.time)<x);this.lg.splice(w,0,d);for(let C=w;C<this.lg.length;++C)pr(this.lg[C].pointData,C);return this.Pu.fillWeightsForPoints(this.lg,w),this.dg(t,w,g)}wg(t,n){const s=this.hg.get(t);if(s===void 0||n<=0)return[[],this.Mg()];n=Math.min(n,s.length);const i=s.splice(-n).reverse();s.length===0?this.ag.delete(t):this.ag.set(t,s[s.length-1].wt);for(const r of i){const o=this.rg.get(this.Pu.key(r.wt));if(o&&(o.ng.delete(t),o.ng.size===0)){this.rg.delete(this.Pu.key(o.Oa)),this.lg.splice(o.$n,1);for(let l=o.$n;l<this.lg.length;++l)pr(this.lg[l].pointData,l)}}return[i,this.dg(t,this.lg.length-1,{fg:!1,Va:!1})]}mg(t,n){let s=this.hg.get(t);s===void 0&&(s=[],this.hg.set(t,s));const i=s.length!==0?s[s.length-1]:null;i===null||this.Pu.key(n.wt)>this.Pu.key(i.wt)?Ms(n)&&s.push(n):Ms(n)?s[s.length-1]=n:s.splice(-1,1),this.ag.set(t,n.wt)}vg(t,n,s){const i=this.hg.get(t);if(i===void 0)return;const r=es(i,s,(o,l)=>o.$n<l);Ms(n)?i[r]=n:i.splice(r,1)}ug(t,n){n.length!==0?(this.hg.set(t,n.filter(Ms)),this.ag.set(t,n[n.length-1].wt)):(this.hg.delete(t),this.ag.delete(t))}_g(){for(const t of this.lg)t.pointData.ng.size===0&&this.rg.delete(this.Pu.key(t.time))}cg(t){let n=-1;for(let s=0;s<this.lg.length&&s<t.length;++s){const i=this.lg[s],r=t[s];if(this.Pu.key(i.time)!==this.Pu.key(r.time)){n=s;break}r.timeWeight=i.timeWeight,pr(r.pointData,s)}if(n===-1&&this.lg.length!==t.length&&(n=Math.min(this.lg.length,t.length)),n===-1)return-1;for(let s=n;s<t.length;++s)pr(t[s].pointData,s);return this.Pu.fillWeightsForPoints(t,n),this.lg=t,n}gg(){if(this.hg.size===0)return null;let t=0;return this.hg.forEach(n=>{n.length!==0&&(t=Math.max(t,n[n.length-1].$n))}),t}dg(t,n,s){const i=this.Mg();if(n!==-1)this.hg.forEach((r,o)=>{i.Y_.set(o,{ue:r,bg:o===t?s:void 0})}),this.hg.has(t)||i.Y_.set(t,{ue:[],bg:s}),i.Et.Sg=this.lg,i.Et.xg=n;else{const r=this.hg.get(t);i.Y_.set(t,{ue:r||[],bg:s})}return i}Mg(){return{Y_:new Map,Et:{Dc:this.gg()}}}}function pr(e,t){e.$n=t,e.ng.forEach(n=>{n.$n=t})}function Kx(e,t){return e._t<t}function Zx(e,t){return t<e._t}function ka(e,t,n,s){return es(e,t,Kx,n,s)}function Ma(e,t,n,s){return wl(e,t,Zx,n,s)}function wr(e,t,n){return{ne:e,se:t,ee:n}}function Su(e,t,n,s){return e>=t-s&&e<=n+s}function mi(e,t,n,s,i,r){const o=i-n,l=r-s;if(o===0&&l===0)return Math.hypot(e-n,t-s);const c=((e-n)*o+(t-s)*l)/(o*o+l*l),h=Math.max(0,Math.min(1,c)),a=n+o*h,u=s+l*h;return Math.hypot(e-a,t-u)}const Uo=[0,0];function tw(e,t,n){return t===void 0||t.wt!==e.wt-1?e._t-n/2:(t._t+e._t)/2}function ew(e,t,n){return t===void 0||t.wt!==e.wt+1?e._t+n/2:(e._t+t._t)/2}function nm(e,t,n,s,i,r,o){if(t===null||t.from>=t.to||e.length===0)return null;const l=i/2+r,c=ka(e,n-l,t.from,t.to),h=Ma(e,n+l,c,t.to);if(c>=h)return null;let a=Number.POSITIVE_INFINITY;for(let u=c;u<h;u++){const f=e[u],p=u>t.from?e[u-1]:void 0,g=u<t.to-1?e[u+1]:void 0,d=tw(f,p,i)-r,w=ew(f,g,i)+r;if(n<d||n>w)continue;o(f,Uo);const C=Uo[0],x=Uo[1],k=Math.min(C,x),S=Math.max(C,x),T=k-r,P=S+r;if(s>=k&&s<=S)a=Math.min(a,0);else if(s>=T&&s<=P){const I=Math.min(Math.abs(s-k),Math.abs(S-s));a=Math.min(a,I)}}return Number.isFinite(a)?wr(a,0,"series-range"):null}function nw(e,t){return e.wt<t}function sw(e,t){return t<e.wt}function iw(e,t,n){const s=t.Na(),i=t.bi(),r=es(e,s,nw),o=wl(e,i,sw);if(!n)return{from:r,to:o};let l=r,c=o;return r>0&&r<e.length&&e[r].wt>=s&&(l=r-1),o>0&&o<e.length&&e[o-1].wt<=i&&(c=o+1),{from:l,to:c}}class Ml{constructor(t,n,s){this.Cg=!0,this.yg=!0,this.Pg=!0,this.kg=[],this.Tg=null,this.Rg=-1,this.ae=t,this.le=n,this.Dg=s}Pt(t){this.Cg=!0,t==="data"&&(this.yg=!0),t==="options"&&(this.Pg=!0)}Tt(){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Vg):null}Qs(t,n){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Bg(t,n)):null}Bg(t,n){return null}Eg(){this.kg=this.kg.map(t=>({...t,...this.ae.Sa().Sh(t.wt)}))}Ag(){this.Tg=null}Ig(){const t=this.le.Et(),n=t.N().enableConflation?t.sd():0;n!==this.Rg&&(this.yg=!0,this.Rg=n),this.yg&&(this.Lg(),this.yg=!1),this.Pg&&(this.Eg(),this.Pg=!1),this.Cg&&(this.zg(),this.Cg=!1)}zg(){const t=this.ae.Ft(),n=this.le.Et();if(this.Ag(),n.Zi()||t.Zi())return;const s=n.Ee();if(s===null||this.ae.Un().Th()===0)return;const i=this.ae.Lt();i!==null&&(this.Tg=iw(this.kg,s,this.Dg),this.Og(t,n,i.Wt),this.Ng())}}class rw{constructor(t,n){this.Fg=t,this.Ki=n}st(t,n,s){this.Fg.draw(t,this.Ki,n,s)}}function ow(e){switch(e){case"point":return 2;case"range":return 0;default:return 1}}class aw extends Ml{constructor(t,n,s){super(t,n,!1),this.Yh=s,this.Fg=this.Yh.renderer(),this.Vg=new rw(this.Fg,i=>this.Wg(i))}get ga(){return this.Yh.conflationReducer}Ha(t){return this.Yh.priceValueBuilder(t)}dl(t){return this.Yh.isWhitespace(t)}Bg(t,n){var o,l;const s=(l=(o=this.Fg).hitTest)==null?void 0:l.call(o,t,n,c=>this.Wg(c));if(s!=null)return{ne:(i=s).distance,se:ow(i.type),ee:"custom",gu:i.cursorStyle,te:i.objectId,ie:i.hitTestData};var i;const r=nm(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(c,h)=>{const a=c.Hg;let u=NaN,f=NaN;if(a!==void 0&&!this.Yh.isWhitespace(a))for(const p of this.Yh.priceValueBuilder(a)){const g=this.Wg(p);g!==null&&(u=Number.isNaN(u)?g:Math.min(u,g),f=Number.isNaN(f)?g:Math.max(f,g))}h[0]=u,h[1]=f});return r===null?null:{...r,ee:"custom"}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>({wt:n.$n,_t:NaN,...t.Sh(n.$n),Hg:n.ue}))}Og(t,n){n.Ic(this.kg,Ni(this.Tg))}Ng(){this.Yh.update({bars:this.kg.map(lw),barSpacing:this.le.Et().ml(),visibleRange:this.Tg,conflationFactor:this.le.Et().sd()},this.ae.N())}Wg(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}}function lw(e){return{x:e._t,time:e.wt,originalData:e.Hg,barColor:e.sh}}const cw={color:"#2196f3"},hw=(e,t,n)=>{const s=Mn(n);return new aw(e,t,s)};function El(e){const t={value:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function Cu(e){const t=El(e);return e.R!==void 0&&(t.color=e.R),t}function uw(e){const t=El(e);return e.vt!==void 0&&(t.lineColor=e.vt),e.ah!==void 0&&(t.topColor=e.ah),e.oh!==void 0&&(t.bottomColor=e.oh),t}function dw(e){const t=El(e);return e._h!==void 0&&(t.topLineColor=e._h),e.uh!==void 0&&(t.bottomLineColor=e.uh),e.dh!==void 0&&(t.topFillColor1=e.dh),e.fh!==void 0&&(t.topFillColor2=e.fh),e.ph!==void 0&&(t.bottomFillColor1=e.ph),e.mh!==void 0&&(t.bottomFillColor2=e.mh),t}function sm(e){const t={open:e.Wt[0],high:e.Wt[1],low:e.Wt[2],close:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function fw(e){const t=sm(e);return e.R!==void 0&&(t.color=e.R),t}function mw(e){const t=sm(e),{R:n,Ht:s,hh:i}=e;return n!==void 0&&(t.color=n),s!==void 0&&(t.borderColor=s),i!==void 0&&(t.wickColor=i),t}function Sr(e){return{Area:uw,Line:Cu,Baseline:dw,Histogram:Cu,Bar:fw,Candlestick:mw,Custom:pw}[e]}function pw(e){const t=e.Qr;return{...e.ue,time:t}}const gw={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1,doNotSnapToHiddenSeriesIndices:!1},yw={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},bw={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:Bf,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Ho={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1,tickMarkDensity:2.5},vw={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:"background"};function ku(){return{addDefaultPane:!0,hoveredSeriesOnTop:!0,width:0,height:0,autoSize:!1,layout:bw,crosshair:gw,grid:yw,overlayPriceScales:{...Ho},leftPriceScale:{...Ho,visible:!1},rightPriceScale:{...Ho,visible:!0},defaultVisiblePriceScaleId:"right",timeScale:vw,localization:{locale:Vs?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class im{constructor(t,n,s){this.hv=t,this.Ug=n,this.$g=s??0}applyOptions(t){this.hv.Qt().Dd(this.Ug,t,this.$g)}options(){return this.Ki().N()}width(){return Qr(this.Ug)?this.hv.DM(this.Ug):0}setVisibleRange(t){this.setAutoScale(!1),this.Ki().Go(new ke(t.from,t.to))}getVisibleRange(){let t,n,s=this.Ki().ar();if(s===null)return null;if(this.Ki().ho()){const i=this.Ki().S_(),r=Kf(i);s=Ns(s,this.Ki().lo()),t=Number((Math.round(s.Je()/i)*i).toFixed(r)),n=Number((Math.round(s.Qe()/i)*i).toFixed(r))}else t=s.Je(),n=s.Qe();return{from:t,to:n}}setAutoScale(t){this.applyOptions({autoScale:t})}Ki(){return K(this.hv.Qt().Id(this.Ug,this.$g)).Ft}}class xw{constructor(t,n,s,i){this.hv=t,this.yt=s,this.jg=n,this.qg=i}getHeight(){return this.yt.$t()}setHeight(t){const n=this.hv.Qt(),s=n._f(this.yt);n.Ld(s,t)}getStretchFactor(){return this.yt.F_()}setStretchFactor(t){this.yt.W_(t),this.hv.Qt().ka()}paneIndex(){return this.hv.Qt()._f(this.yt)}moveTo(t){const n=this.paneIndex();n!==t&&(pe(t>=0&&t<this.hv.lv().length,"Invalid pane index"),this.hv.Qt().Od(n,t))}getSeries(){return this.yt.Y_().map(t=>this.jg(t))??[]}getHTMLElement(){const t=this.hv.lv();return t&&t.length!==0&&t[this.paneIndex()]?t[this.paneIndex()].fv():null}attachPrimitive(t){this.yt.ol(t),t.attached&&t.attached({chart:this.qg,requestUpdate:()=>this.yt.Qt().ka()})}detachPrimitive(t){this.yt._l(t)}priceScale(t){if(this.yt.O_(t)===null)throw new Error(`Cannot find price scale with id: ${t}`);return new im(this.hv,t,this.paneIndex())}setPreserveEmptyPane(t){this.yt.j_(t)}preserveEmptyPane(){return this.yt.q_()}addCustomSeries(t,n={},s=0){return this.qg.addCustomSeries(t,n,s)}addSeries(t,n={}){return this.qg.addSeries(t,n,this.paneIndex())}}const ww={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Mu{constructor(t){this._r=t}applyOptions(t){this._r.vr(t)}options(){return this._r.N()}Yg(){return this._r}}class Sw{constructor(t,n,s,i,r,o){this.Kg=new Zt,this.ae=t,this.Gg=n,this.Zg=s,this.Pu=r,this.qg=i,this.Xg=o}m(){this.Kg.m()}priceFormatter(){return this.ae.sl()}priceToCoordinate(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}coordinateToPrice(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Tn(t,n.Wt)}barsInLogicalRange(t){if(t===null)return null;const n=new Ls(new Si(t.from,t.to)).Uu(),s=this.ae.Un();if(s.Zi())return null;const i=s.Hn(n.Na(),1),r=s.Hn(n.bi(),-1),o=K(s.Rh()),l=K(s.Qn());if(i!==null&&r!==null&&i.$n>r.$n)return{barsBefore:t.from-o,barsAfter:l-t.to};const c={barsBefore:i===null||i.$n===o?t.from-o:i.$n-o,barsAfter:r===null||r.$n===l?l-t.to:l-r.$n};return i!==null&&r!==null&&(c.from=i.Qr,c.to=r.Qr),c}setData(t){this.Pu,this.ae.bh(),this.Gg.Jg(this.ae,t),this.Qg("full")}update(t,n=!1){this.ae.bh(),this.Gg.tb(this.ae,t,n),this.Qg("update")}pop(t=1){const n=this.Gg.ib(this.ae,t);n.length!==0&&this.Qg("update");const s=Sr(this.seriesType());return n.map(i=>s(i))}dataByIndex(t,n){const s=this.ae.Un().Hn(t,n);return s===null?null:Sr(this.seriesType())(s)}data(){const t=Sr(this.seriesType());return this.ae.Un().Bh().map(n=>t(n))}subscribeDataChanged(t){this.Kg.i(t)}unsubscribeDataChanged(t){this.Kg._(t)}applyOptions(t){this.ae.vr(t)}options(){return an(this.ae.N())}priceScale(){return this.Zg.priceScale(this.ae.Ft().pl(),this.getPane().paneIndex())}createPriceLine(t){const n=$e(an(ww),t),s=this.ae.Ea(n);return new Mu(s)}removePriceLine(t){this.ae.Aa(t.Yg())}priceLines(){return this.ae.La().map(t=>new Mu(t))}seriesType(){return this.ae.bh()}lastValueData(t){const n=this.ae.Ae(t);return n.Le?{noData:!0}:{noData:!1,price:n.Mt,color:n.R}}attachPrimitive(t){this.ae.ol(t),t.attached&&t.attached({chart:this.qg,series:this,requestUpdate:()=>this.ae.Qt().ka(),horzScaleBehavior:this.Pu})}detachPrimitive(t){this.ae._l(t),t.detached&&t.detached(),this.ae.Qt().ka()}getPane(){const t=this.ae,n=K(this.ae.Qt().Ks(t));return this.Xg(n)}moveToPane(t){this.ae.Qt().rf(this.ae,t)}seriesOrder(){const t=this.ae.Qt().Ks(this.ae);return t===null?-1:t.Y_().indexOf(this.ae)}setSeriesOrder(t){const n=this.ae.Qt().Ks(this.ae);n!==null&&n.vu(this.ae,t)}Qg(t){this.Kg.v()&&this.Kg.p(t)}}class Cw{constructor(t,n,s){this.nb=new Zt,this.Qu=new Zt,this.Nw=new Zt,this.sn=t,this.ia=t.Et(),this.vM=n,this.ia.Zc().i(this.sb.bind(this)),this.ia.Xc().i(this.eb.bind(this)),this.vM.qw().i(this.rb.bind(this)),this.Pu=s}m(){this.ia.Zc().u(this),this.ia.Xc().u(this),this.vM.qw().u(this),this.nb.m(),this.Qu.m(),this.Nw.m()}scrollPosition(){return this.ia.Oc()}scrollToPosition(t,n){n?this.ia.Yc(t,1e3):this.sn.gs(t)}scrollToRealTime(){this.ia.qc()}getVisibleRange(){const t=this.ia.xc();return t===null?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const n={from:this.Pu.convertHorzItemToInternal(t.from),to:this.Pu.convertHorzItemToInternal(t.to)},s=this.ia.kc(n);this.sn.sf(s)}getVisibleLogicalRange(){const t=this.ia.Sc();return t===null?null:{from:t.Na(),to:t.bi()}}setVisibleLogicalRange(t){pe(t.from<=t.to,"The from index cannot be after the to index."),this.sn.sf(t)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.td()}logicalToCoordinate(t){const n=this.sn.Et();return n.Zi()?null:n.jt(t)}coordinateToLogical(t){return this.ia.Zi()?null:this.ia.Vc(t)}timeToIndex(t,n){const s=this.Pu.convertHorzItemToInternal(t);return this.ia.Mc(s,n)}timeToCoordinate(t){const n=this.timeToIndex(t,!1);return n===null?null:this.ia.jt(n)}coordinateToTime(t){const n=this.sn.Et(),s=n.Vc(t),i=n.en(s);return i===null?null:i.originalTime}width(){return this.vM.pv().width}height(){return this.vM.pv().height}subscribeVisibleTimeRangeChange(t){this.nb.i(t)}unsubscribeVisibleTimeRangeChange(t){this.nb._(t)}subscribeVisibleLogicalRangeChange(t){this.Qu.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.Qu._(t)}subscribeSizeChange(t){this.Nw.i(t)}unsubscribeSizeChange(t){this.Nw._(t)}applyOptions(t){this.ia.vr(t)}options(){return{...an(this.ia.N()),barSpacing:this.ia.ml()}}sb(){this.nb.v()&&this.nb.p(this.getVisibleRange())}eb(){this.Qu.v()&&this.Qu.p(this.getVisibleLogicalRange())}rb(t){this.Nw.p(t.width,t.height)}}function Eu(e){return function(t){if(or(t.handleScale)){const s=t.handleScale;t.handleScale={axisDoubleClickReset:{time:s,price:s},axisPressedMouseMove:{time:s,price:s},mouseWheel:s,pinch:s}}else if(t.handleScale!==void 0){const{axisPressedMouseMove:s,axisDoubleClickReset:i}=t.handleScale;or(s)&&(t.handleScale.axisPressedMouseMove={time:s,price:s}),or(i)&&(t.handleScale.axisDoubleClickReset={time:i,price:i})}const n=t.handleScroll;or(n)&&(t.handleScroll={horzTouchDrag:n,vertTouchDrag:n,mouseWheel:n,pressedMouseMove:n})}(e),e}class kw{constructor(t,n,s){this.hb=new Map,this.ab=new Map,this.lb=new Zt,this.ob=new Zt,this._b=new Zt,this.dd=new WeakMap,this.ub=new Jx(n);const i=s===void 0?an(ku()):$e(an(ku()),Eu(s));this.cb=n,this.hv=new Ox(t,i,n),this.hv.mw().i(o=>{this.lb.v()&&this.lb.p(this.fb(o()))},this),this.hv.ww().i(o=>{this.ob.v()&&this.ob.p(this.fb(o()))},this),this.hv.Bd().i(o=>{this._b.v()&&this._b.p(this.fb(o()))},this);const r=this.hv.Qt();this.pb=new Cw(r,this.hv.bM(),this.cb)}remove(){this.hv.mw().u(this),this.hv.ww().u(this),this.hv.Bd().u(this),this.pb.m(),this.hv.m(),this.hb.clear(),this.ab.clear(),this.lb.m(),this.ob.m(),this._b.m(),this.ub.m()}resize(t,n,s){this.autoSizeActive()||this.hv.wM(t,n,s)}addCustomSeries(t,n={},s=0){const i=(r=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...cw,...r.defaultOptions()},mb:hw,wb:r}))(Mn(t));return this.Mb(i,n,s)}addSeries(t,n={},s=0){return this.Mb(t,n,s)}removeSeries(t){const n=Re(this.hb.get(t)),s=this.ub.if(n);this.hv.Qt().if(n),this.gb(s),this.hb.delete(t),this.ab.delete(n)}Jg(t,n){this.gb(this.ub.og(t,n))}tb(t,n,s){this.gb(this.ub.pg(t,n,s))}ib(t,n){const[s,i]=this.ub.wg(t,n);return s.length!==0&&this.gb(i),s}subscribeClick(t){this.lb.i(t)}unsubscribeClick(t){this.lb._(t)}subscribeCrosshairMove(t){this._b.i(t)}unsubscribeCrosshairMove(t){this._b._(t)}subscribeDblClick(t){this.ob.i(t)}unsubscribeDblClick(t){this.ob._(t)}priceScale(t,n=0){return new im(this.hv,t,n)}timeScale(){return this.pb}applyOptions(t){this.hv.vr(Eu(t))}options(){return this.hv.N()}takeScreenshot(t=!1,n=!1){let s,i;try{n||(s=this.hv.Qt().N().crosshair.mode,this.hv.vr({crosshair:{mode:2}})),i=this.hv.TM(t)}finally{n||s===void 0||this.hv.Qt().vr({crosshair:{mode:s}})}return i}addPane(t=!1){const n=this.hv.Qt().uf();return n.j_(t),this.bb(n)}removePane(t){this.hv.Qt().Ad(t)}swapPanes(t,n){this.hv.Qt().zd(t,n)}autoSizeActive(){return this.hv.CM()}chartElement(){return this.hv.Mv()}panes(){return this.hv.Qt().Gn().map(t=>this.bb(t))}paneSize(t=0){const n=this.hv.AM(t);return{height:n.height,width:n.width}}setCrosshairPosition(t,n,s){const i=this.hb.get(s);if(i===void 0)return;const r=this.hv.Qt().Ks(i);r!==null&&this.hv.Qt().Gd(t,n,r)}clearCrosshairPosition(){this.hv.Qt().Zd(!0)}horzBehaviour(){return this.cb}Mb(t,n={},s=0){pe(t.mb!==void 0),function(c){if(c===void 0||c.type==="custom")return;const h=c;h.minMove!==void 0&&h.precision===void 0&&(h.precision=Kf(h.minMove))}(n.priceFormat),t.type==="Candlestick"&&function(c){c.borderColor!==void 0&&(c.borderUpColor=c.borderColor,c.borderDownColor=c.borderColor),c.wickColor!==void 0&&(c.wickUpColor=c.wickColor,c.wickDownColor=c.wickColor)}(n);const i=$e(an(zf),an(t.defaultOptions),n),r=t.mb,o=new Kr(this.hv.Qt(),t.type,i,r,t.wb);this.hv.Qt().Qd(o,s);const l=new Sw(o,this,this,this,this.cb,c=>this.bb(c));return this.hb.set(l,o),this.ab.set(o,l),l}gb(t){const n=this.hv.Qt();for(const s of t.Y_.keys())s.Ia();n.Xd(t.Et.Dc,t.Et.Sg,t.Et.xg),t.Y_.forEach((s,i)=>i.ht(s.ue,s.bg)),n.Et().dc(),n.Lc()}Sb(t){return Re(this.ab.get(t))}xb(t){return t!==void 0&&this.ab.has(t)?this.Sb(t):void 0}fb(t){const n=new Map;t.QM.forEach((r,o)=>{const l=o.bh(),c=Sr(l)(r);if(l!=="Custom")pe(Hx(c));else{const h=o.cl();pe(!h||h(c)===!1)}n.set(this.Sb(o),c)});const s=this.xb(t.jM),i=t.YM===void 0?void 0:{type:t.YM.ds,sourceKind:t.YM.KM,objectKind:t.YM.GM,series:this.xb(t.YM.Y_),objectId:t.YM.ZM,paneIndex:t.YM.XM};return{time:t.Qr,logical:t.$n,point:t.JM,paneIndex:t.XM,hoveredInfo:i,hoveredSeries:s,hoveredObjectId:t.qM,seriesData:n,sourceEvent:t.tg}}bb(t){let n=this.dd.get(t);return n||(n=new xw(this.hv,s=>this.Sb(s),t,this),this.dd.set(t,n)),n}}function Mw(e){if(Bi(e)){const t=document.getElementById(e);return pe(t!==null,`Cannot find element in DOM with id=${e}`),t}return e}function Ew(e,t,n){const s=Mw(e),i=new kw(s,t,n);return t.setOptions(i.options()),i}function Tw(e,t){return Ew(e,new cu,cu.Tf(t))}function li(e,t,n,s){return Math.hypot(n-e,s-t)}function rm(e,t,n,s,i,r,o,l=0){if(t.length===0||s.from>=t.length||s.to<=0)return;const{context:c,horizontalPixelRatio:h,verticalPixelRatio:a}=e,u=t[s.from];let f=r(e,u),p=u;if(s.to-s.from<2){const g=i/2;c.beginPath();const d={_t:u._t-g,ut:u.ut},w={_t:u._t+g,ut:u.ut};c.moveTo(d._t*h,d.ut*a),c.lineTo(w._t*h,w.ut*a),o(e,f,d,w)}else{const g=l>0;let d=0;const w=(x,k)=>{if(o(e,f,p,k),c.beginPath(),f=x,p=k,g){const S=d%l;c.lineDashOffset=S,d=S}};let C=p;c.beginPath(),c.moveTo(u._t*h,u.ut*a);for(let x=s.from+1;x<s.to;++x){C=t[x];const k=C._t*h,S=C.ut*a,T=r(e,C);switch(n){case 0:if(c.lineTo(k,S),g){const P=t[x-1],I=P._t*h,L=P.ut*a;d+=li(I,L,k,S)}break;case 1:{const P=t[x-1],I=P.ut*a;c.lineTo(k,I),g&&(d+=Math.abs(C._t-P._t)*h),T!==f&&(w(T,C),c.lineTo(k,I)),c.lineTo(k,S),g&&(d+=Math.abs(C.ut-P.ut)*a);break}case 2:{const[P,I]=Tl(t,x-1,x),L=P._t*h,O=P.ut*a,H=I._t*h,U=I.ut*a;if(c.bezierCurveTo(L,O,H,U,k,S),g){const q=t[x-1],X=q._t*h,V=q.ut*a,D=li(X,V,k,S),j=li(X,V,L,O)+li(L,O,H,U)+li(H,U,k,S);d+=(D+j)/2}break}}n!==1&&T!==f&&(w(T,C),c.moveTo(k,S))}(p!==C||p===C&&n===1)&&o(e,f,p,C),g&&(c.lineDashOffset=0)}}const Tu=6;function qo(e,t){return{_t:e._t-t._t,ut:e.ut-t.ut}}function Au(e,t){return{_t:e._t/t,ut:e.ut/t}}function Tl(e,t,n){const s=Math.max(0,t-1),i=Math.min(e.length-1,n+1);var r,o;return[(r=e[t],o=Au(qo(e[n],e[s]),Tu),{_t:r._t+o._t,ut:r.ut+o.ut}),qo(e[n],Au(qo(e[i],e[t]),Tu))]}function Aw(e,t){const n=e.context;n.strokeStyle=t,n.stroke()}class Rw extends $n{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:s,Cb:i,yb:r,ct:o,Gt:l,Pb:c}=this.rt;if(s===null)return;const h=t.context;h.lineCap="butt",h.lineWidth=o*t.verticalPixelRatio;const a=Pn(h,l);h.lineJoin="round";const u=this.kb.bind(this),f=function(p){return p.reduce((g,d)=>g+d,0)}(a);r!==void 0&&rm(t,n,r,s,i,u,Aw,f),c&&function(p,g,d,w,C){if(w.to-w.from<=0)return;const{horizontalPixelRatio:x,verticalPixelRatio:k,context:S}=p;let T=null;const P=Math.max(1,Math.floor(x))%2/2,I=d*k+P;for(let L=w.to-1;L>=w.from;--L){const O=g[L];if(O){const H=C(p,O);H!==T&&(T!==null&&S.fill(),S.beginPath(),S.fillStyle=H,T=H);const U=Math.round(O._t*x)+P,q=O.ut*k;S.moveTo(U,q),S.arc(U,q,I,0,2*Math.PI)}}S.fill()}(t,n,c,s,u)}}class om extends Rw{kb(t,n){return n.vt}}function Ru(e,t,n,s,i){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function Pw(e,t,n,s,i){if(n===2){const[r,o]=Tl(s,i-1,i);return[Math.min(e._t,t._t,r._t,o._t),Math.max(e._t,t._t,r._t,o._t)]}return[Math.min(e._t,t._t),Math.max(e._t,t._t)]}function _w(e,t,n,s,i,r,o,l){switch(i){case 1:{const c=mi(e,t,n._t,n.ut,s._t,n.ut),h=mi(e,t,s._t,n.ut,s._t,s.ut),a=Math.min(c,h);return a<=l?a:null}case 2:{const[c,h]=Tl(r,o-1,o),a=function(u,f,p){let g=Number.POSITIVE_INFINITY,d=p[0];for(let w=1;w<=12;w++){const C=w/12,x={_t:Ru(p[0]._t,p[1]._t,p[2]._t,p[3]._t,C),ut:Ru(p[0].ut,p[1].ut,p[2].ut,p[3].ut,C)};g=Math.min(g,mi(u,f,d._t,d.ut,x._t,x.ut)),d=x}return g}(e,t,[n,c,h,s]);return a<=l?a:null}default:{const c=mi(e,t,n._t,n.ut,s._t,s.ut);return c<=l?c:null}}}class $w extends Ml{constructor(t,n){super(t,n,!0)}Og(t,n,s){n.Ic(this.kg,Ni(this.Tg)),t.Jo(this.kg,s,Ni(this.Tg))}Tb(t,n){return{wt:t,Mt:n,_t:NaN,ut:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>{let s;if((n.Gr??1)>1){const i=n.Wt[1],r=n.Wt[2],o=n.Wt[3];s=Math.abs(i-o)>Math.abs(r-o)?i:r}else s=n.Wt[3];return this.Rb(n.$n,s,t)})}}class am extends $w{Bg(t,n){const s=this.ae.N();return function(i,r,o,l,c,h,a,u=0,f=0){if(r===null||r.from>=r.to||i.length===0)return null;const p=Math.max(h/2,a??0)+f;let g=Number.POSITIVE_INFINITY;if(a!==void 0){const S=a+f,T=ka(i,o-S,r.from,r.to),P=Ma(i,o+S,T,r.to);for(let I=T;I<P;I++){const L=i[I];if(!Su(o,L._t,L._t,a+f))continue;const O=Math.hypot(o-L._t,l-L.ut);O<=a+f&&(g=Math.min(g,O))}}if(r.to-r.from<2){const S=i[r.from],T=Math.max(u/2,p),P=mi(o,l,S._t-T,S.ut,S._t+T,S.ut);return P<=p&&(g=Math.min(g,P)),Number.isFinite(g)?wr(g,2,"series-point"):null}let d=Number.POSITIVE_INFINITY;const w=ka(i,o-p,r.from,r.to),C=Ma(i,o+p,w,r.to),x=Math.max(r.from+1,w),k=Math.min(r.to,C+1);for(let S=x;S<k;S++){const T=i[S-1],P=i[S],[I,L]=Pw(T,P,c,i,S);if(!Su(o,I,L,p))continue;const O=_w(o,l,T,P,c,i,S,p);O!==null&&(d=Math.min(d,O))}return Number.isFinite(g)?wr(g,2,"series-point"):Number.isFinite(d)?wr(d,1,"series-line"):null}(this.kg,this.Tg,t,n,s.lineType,s.lineVisible?s.lineWidth:1,s.pointMarkersVisible?s.pointMarkersRadius||s.lineWidth/2+2:void 0,this.le.Et().ml(),s.hitTestTolerance)}}class Nw extends am{constructor(){super(...arguments),this.Vg=new om}Rb(t,n,s){return{...this.Tb(t,n),...s.Sh(t)}}Ng(){const t=this.ae.N(),n={ot:this.kg,Gt:t.lineStyle,yb:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Tg,Cb:this.le.Et().ml()};this.Vg.ht(n)}}const Iw={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Nw(e,t)};function Dw(e,t,n,s,i){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;r.lineTo(i._t*o,e*l),r.lineTo(s._t*o,e*l),r.closePath(),r.fillStyle=n,r.fill()}class Lw extends $n{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:s,Cb:i,ct:r,Gt:o,yb:l}=this.rt,c=this.rt.Lb??(this.rt.zb?0:t.mediaSize.height);if(s===null)return;const h=t.context;h.lineCap="butt",h.lineJoin="round",h.lineWidth=r,Pn(h,o),h.lineWidth=1,rm(t,n,l,s,i,this.Ob.bind(this),Dw.bind(null,c))}}class zw{Nb(t,n){const s=this.Fb,{Wb:i,Hb:r,Ub:o,$b:l,Lb:c,jb:h,qb:a}=n;if(this.Yb===void 0||s===void 0||s.Wb!==i||s.Hb!==r||s.Ub!==o||s.$b!==l||s.Lb!==c||s.jb!==h||s.qb!==a){const{verticalPixelRatio:u}=t,f=c||h>0?u:1,p=h*f,g=a===t.bitmapSize.height?a:a*f,d=(c??0)*f,w=t.context.createLinearGradient(0,p,0,g);if(w.addColorStop(0,i),c!=null){const C=Ds((d-p)/(g-p),0,1);w.addColorStop(C,r),w.addColorStop(C,o)}w.addColorStop(1,l),this.Yb=w,this.Fb=n}return this.Yb}}class Fw{constructor(t,n,s,i){this.Zb=t,this.Xb=n,this.Jb=s,this.Qb=i}st(t,n,s){this.Zb.st(t,n,s),!this.Jb()||n&&this.Qb()||this.Xb.st(t,n,s)}}class Bw{constructor(t,n){this.Xb=t,this.tS=n}Tt(){return this.tS()?this.Xb:null}}class Ww extends Lw{constructor(){super(...arguments),this.Kb=new zw}Ob(t,n){var s;return this.Kb.Nb(t,{Wb:n.ah,Hb:"",Ub:"",$b:n.oh,jb:((s=this.rt)==null?void 0:s.jb)??0,qb:t.bitmapSize.height})}}class Vw extends am{constructor(t,n){super(t,n),this.lS=new Ww,this.Xb=new om,this.sS=new Bw(this.Xb,()=>this.Jb()),this.eS=[this],this.rS=[this.sS],this.hS={Za:this.eS,qa:this.rS},this.Vg=new Fw(this.lS,this.Xb,()=>this.Jb(),()=>this.le.N().hoveredSeriesOnTop)}Ga(){return this.hS}Rb(t,n,s){return{...this.Tb(t,n),...s.Sh(t)}}Ng(){const t=this.ae.N();if(this.Tg===null||this.kg.length===0)return;let n;if(t.relativeGradient){n=this.kg[this.Tg.from].ut;for(let s=this.Tg.from;s<this.Tg.to;s++){const i=this.kg[s];i.ut<n&&(n=i.ut)}}this.lS.ht({yb:t.lineType,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,Lb:null,jb:n,zb:t.invertFilledArea,lt:this.Tg,Cb:this.le.Et().ml()}),this.Xb.ht({yb:t.lineVisible?t.lineType:void 0,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,lt:this.Tg,Cb:this.le.Et().ml(),Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}Jb(){return this.ae.It()&&this.Tg!==null&&this.aS()}aS(){const t=this.ae.N();return t.lineVisible||t.pointMarkersVisible}}const jw={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Vw(e,t)};class Ow extends Ml{constructor(t,n){super(t,n,!1)}Bg(t,n){return nm(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(s,i)=>{i[0]=s.n_,i[1]=s.s_})}Og(t,n,s){n.Ic(this.kg,Ni(this.Tg)),t.t_(this.kg,s,Ni(this.Tg))}fS(t,n,s){return{wt:t,jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3],_t:NaN,i_:NaN,n_:NaN,s_:NaN,e_:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>this.Rb(n.$n,n,t))}}class Uw extends $n{constructor(){super(...arguments),this.qt=null,this.oS=0}ht(t){this.qt=t}et(t){if(this.qt===null||this.qt.Un.length===0||this.qt.lt===null)return;const{horizontalPixelRatio:n}=t;this.oS=function(r,o){if(r>=2.5&&r<=4)return Math.floor(3*o);const l=1-.2*Math.atan(Math.max(4,r)-4)/(.5*Math.PI),c=Math.floor(r*l*o),h=Math.floor(r*o),a=Math.min(c,h);return Math.max(Math.floor(o),a)}(this.qt.ml,n),this.oS>=2&&Math.floor(n)%2!=this.oS%2&&this.oS--;const s=this.qt.Un;this.qt.pS&&this.vS(t,s,this.qt.lt),this.qt.gi&&this.Vm(t,s,this.qt.lt);const i=this.mS(n);(!this.qt.gi||this.oS>2*i)&&this.wS(t,s,this.qt.lt)}vS(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="",c=Math.min(Math.floor(r),Math.floor(this.qt.ml*r));c=Math.max(Math.floor(r),Math.min(c,this.oS));const h=Math.floor(.5*c);let a=null;for(let u=s.from;u<s.to;u++){const f=n[u];f.rh!==l&&(i.fillStyle=f.rh,l=f.rh);const p=Math.round(Math.min(f.i_,f.e_)*o),g=Math.round(Math.max(f.i_,f.e_)*o),d=Math.round(f.n_*o),w=Math.round(f.s_*o);let C=Math.round(r*f._t)-h;const x=C+c-1;a!==null&&(C=Math.max(a+1,C),C=Math.min(C,x));const k=x-C+1;i.fillRect(C,d,k,p-d),i.fillRect(C,g+1,k,w-g),a=x}}mS(t){let n=Math.floor(1*t);this.oS<=2*n&&(n=Math.floor(.5*(this.oS-1)));const s=Math.max(Math.floor(t),n);return this.oS<=2*s?Math.max(Math.floor(t),Math.floor(1*t)):s}Vm(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const c=this.mS(r);let h=null;for(let a=s.from;a<s.to;a++){const u=n[a];u.eh!==l&&(i.fillStyle=u.eh,l=u.eh);let f=Math.round(u._t*r)-Math.floor(.5*this.oS);const p=f+this.oS-1,g=Math.round(Math.min(u.i_,u.e_)*o),d=Math.round(Math.max(u.i_,u.e_)*o);if(h!==null&&(f=Math.max(h+1,f),f=Math.min(f,p)),this.qt.ml*r>2*c)Rv(i,f,g,p-f+1,d-g+1,c);else{const w=p-f+1;i.fillRect(f,g,w,d-g+1)}h=p}}wS(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const c=this.mS(r);for(let h=s.from;h<s.to;h++){const a=n[h];let u=Math.round(Math.min(a.i_,a.e_)*o),f=Math.round(Math.max(a.i_,a.e_)*o),p=Math.round(a._t*r)-Math.floor(.5*this.oS),g=p+this.oS-1;if(a.sh!==l){const d=a.sh;i.fillStyle=d,l=d}this.qt.gi&&(p+=c,u+=c,g-=c,f-=c),u>f||i.fillRect(p,u,g-p+1,f-u+1)}}}class Hw extends Ow{constructor(){super(...arguments),this.Vg=new Uw}Rb(t,n,s){return{...this.fS(t,n,s),...s.Sh(t)}}Ng(){const t=this.ae.N();this.Vg.ht({Un:this.kg,ml:this.le.Et().ml(),pS:t.wickVisible,gi:t.borderVisible,lt:this.Tg})}}const qw={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},mb:(e,t)=>new Hw(e,t)};({...zf});const Gw=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},Br=(...e)=>{Gw()&&console.warn(...e)};function Yw(e,t,n){var o,l;const s=t.expression?((o=e.evaluateExpression)==null?void 0:o.call(e,t.expression,t.expressionUrl,n,t.expressionKey))??e.interpolateText(t.expression):e.interpolateText(t.text||"");if(t.className){const c=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const a=vl(t.className);if(a.size>0){const f=ht(a,e.containerWidth,"1rem");c.fontSize=f}const u=Gs(t.className);u.size>0&&(c.display=ht(u,e.containerWidth,"block"))}const h=e.getCommonProps(n,c,t);return E("p",{key:n,className:t.className,...h},s)}const i={color:e.cfg.colors.text};t.fontSize!==void 0&&(i.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(i.fontWeight=t.fontWeight),t.color!==void 0&&(i.color=t.color),t.textAlign!==void 0&&(i.textAlign=t.textAlign);const r=e.getCommonProps(n,i,t);return E("p",{key:n,...r},s)}function Xw(e){return e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<iframe[\s\S]*?<\/iframe>/gi,"").replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"")}function Qw(e,t,n){const s=String(e.apiUrl||"").replace(/\/$/,""),i=e.interpolateText(t.text||t.html||"").replace(/(src|href)=("|')\/(?!\/)/g,s?`$1=$2${s}/`:"$1=$2/"),r=e.getCommonProps(n,{color:e.cfg.colors.text},t);return E("div",{key:n,className:t.className,...r,dangerouslySetInnerHTML:{__html:Xw(i)}})}function Jw(e,t,n){var l,c,h,a,u;const s=()=>{t.onClick?e.handleButtonClick(t.onClick,{onSuccess:t.onSuccess,onError:t.onError},{optimistic:t.optimistic,feedback:t.feedback}):t.href&&(t.href.startsWith("http")||e.previewMode?window.open(t.href,"_blank","noopener,noreferrer"):window.location.href=t.href)},i=()=>{var f;if(!e.interactionDisabled){if((f=t.confirmation)!=null&&f.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:14}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{s()}});return}s()}};if(t.className){const f=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const g=Gs(t.className);g.size>0&&(f.display=ht(g,e.containerWidth,"inline"));const d=vl(t.className);if(d.size>0){const w=ht(d,e.containerWidth,"1rem");f.fontSize=w}}t.icon&&(f.display="inline-flex",f.alignItems="center",f.gap=6);const p=e.getCommonProps(n,f,t);return E("a",{key:n,className:t.className,...p,onClick:e.interactionDisabled?void 0:i,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(c=t.href)!=null&&c.startsWith("http")?"_blank":void 0,rel:(h=t.href)!=null&&h.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}const r={cursor:"pointer",textDecoration:"none",transition:"all 0.2s",display:"inline-flex",alignItems:"center",gap:6},o=e.getCommonProps(n,r,t);return E("a",{key:n,...o,onClick:e.interactionDisabled?void 0:i,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(a=t.href)!=null&&a.startsWith("http")?"_blank":void 0,rel:(u=t.href)!=null&&u.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}function Kw(e,t,n){var g,d,w,C,x;let s=!1;if(t.activeWhen){if(t.activeWhen===e.currentSceneId)s=!0;else if(typeof t.activeWhen=="string"){const k=t.activeWhen.split("=",2);k.length===2&&(s=String(((g=e.sceneData)==null?void 0:g[k[0]])??"")===k[1])}}const i=s?{onClick:t.activeOnClick||t.onClick,onSuccess:t.activeOnSuccess||t.onSuccess,onError:t.activeOnError||t.onError,icon:t.activeIcon||t.icon,text:t.activeText||t.text,label:t.activeText||t.label}:{onClick:t.onClick,onSuccess:t.onSuccess,onError:t.onError,icon:t.icon,text:t.text,label:t.label},r=t.disabled?((d=e.evaluateCondition)==null?void 0:d.call(e,t.disabled))??!1:!1,o=k=>{const S=()=>e.handleButtonClick(i.onClick||"",{onSuccess:i.onSuccess,onError:i.onError},{optimistic:t.optimistic,feedback:t.feedback,refetchScope:t.refetchScope,mergeResponse:t.mergeResponse,anchorElement:k==null?void 0:k.currentTarget});(e.withLoading?e.withLoading(n,S):S()).catch(P=>{var L,O;const I=((L=t.onError)==null?void 0:L.message)||(P==null?void 0:P.message)||"An error occurred";(O=e.showToast)==null||O.call(e,I,"error")})},l=k=>{var S;if((S=t.confirmation)!=null&&S.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:16}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{o(k)}});return}o(k)},c=(w=e.buttonLoading)==null?void 0:w[n];if(t.className){let k=((C=e.parseClassNameResponsive)==null?void 0:C.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const U=Gs(t.className);U.size>0&&(k.display=ht(U,e.containerWidth,"inline-flex"));const q=vl(t.className);q.size>0&&(k.fontSize=ht(q,e.containerWidth,"1rem"))}let S=t.className;if(s&&t.activeClass){const U=((x=e.parseClassNameResponsive)==null?void 0:x.call(e,t.activeClass,n))??e.parseClassName(t.activeClass);k={...k,...U},S=`${t.className} ${t.activeClass}`}const T={display:"inline-flex",alignItems:"center",justifyContent:k.textAlign==="left"?"flex-start":k.textAlign==="right"?"flex-end":"center",gap:"6px",...k,...t.color&&{color:t.color},...t.background&&{background:t.background},...t.borderRadius!==void 0&&{borderRadius:typeof t.borderRadius=="number"?`${t.borderRadius}px`:t.borderRadius},...t.borderColor&&{borderColor:t.borderColor},...c&&{opacity:.6,pointerEvents:"none"}},P={},I=(t.className||"").split(/\s+/).filter(Boolean);for(const U of I)if(U.startsWith("hover:")){const q=U.replace("hover:","");if(q.startsWith("bg-")||q.startsWith("text-")||q.startsWith("border-")){const X=e.parseClassName(q);Object.assign(P,X)}}const L=e.getCommonProps(n,T,t),O=[];i.icon&&!c&&O.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...i.text?{marginRight:"6px"}:{}}},e.renderIcon(i.icon,t.iconSize||16))),c&&O.unshift(E("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),Array.isArray(t.children)&&t.children.length>0?t.children.forEach((U,q)=>{O.push(e.renderComponent(U,q,n))}):O.push(i.label||i.text||(i.icon?"":"Button"));const H={};return Object.keys(P).length>0&&(H.onMouseEnter=U=>{P.backgroundColor&&(U.currentTarget.style.backgroundColor=P.backgroundColor),P.color&&(U.currentTarget.style.color=P.color),P.borderColor&&(U.currentTarget.style.borderColor=P.borderColor)},H.onMouseLeave=U=>{P.backgroundColor&&(U.currentTarget.style.backgroundColor=T.backgroundColor||""),P.color&&(U.currentTarget.style.color=T.color||""),P.borderColor&&(U.currentTarget.style.borderColor=T.borderColor||"")}),E("button",{key:n,className:S,title:e.interpolateText(t.tooltip||t.ariaLabel||i.label||i.text||"Button"),...L,...H,onClick:e.interactionDisabled?void 0:l,disabled:c||r||void 0},...O)}const h=e.cfg.colors.primary,a=e.cfg.colors.accent,u={display:"inline-flex",alignItems:"center",gap:"6px",padding:"0.75rem 1.5rem",borderRadius:"0.75rem",fontWeight:600,transition:e.cfg.effects.transition,color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.text,background:s?e.cfg.colors.primary:`linear-gradient(to right, ${h}, ${a})`,boxShadow:s?"none":`0 10px 15px -3px ${h}40`,...c&&{opacity:.6,pointerEvents:"none"}},f=e.getCommonProps(n,u,t),p=[];return c&&p.push(E("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),i.icon&&!c&&p.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(i.icon,t.iconSize||16))),p.push(i.label||i.text||(i.icon?"":"Button")),E("button",{key:n,title:e.interpolateText(t.tooltip||t.ariaLabel||i.label||i.text||"Button"),...f,onClick:e.interactionDisabled?void 0:l,disabled:c||r||void 0},...p)}function Zw(e,t,n){var h;const s=e.interpolateText(t.src||""),i=!s||s==="placeholder",r=e.imageErrors[n];if(t.skipEmpty&&i)return null;const o={border:`1px dashed ${e.cfg.colors.borderSubtle}`,display:"flex",alignItems:"center",justifyContent:"center",padding:10,height:"200px",borderRadius:"0.75rem"};if(i){const a=e.getCommonProps(n,o,t);return E("div",{key:n,...a},E("span",{style:{color:e.cfg.colors.textPlaceholder,fontSize:"0.875rem"}},"Image"))}if(r)return null;if(t.className){const a=((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className),u=e.getCommonProps(n,a,t),f={key:`${n}-${s}`,src:s,alt:t.alt||"",className:t.className,...u,onError:()=>e.setImageErrors(p=>({...p,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(f.onClick=()=>e.handleButtonClick(t.onClick)),E("img",f)}const l={width:t.w||t.width||"100%",height:t.h||t.height||"auto",objectFit:"cover",borderRadius:"0.75rem"};t.onClick&&(l.cursor="pointer");const c={key:`${n}-${s}`,src:s,alt:t.alt||"",...e.getCommonProps(n,l,t),onError:()=>e.setImageErrors(a=>({...a,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(c.onClick=()=>e.handleButtonClick(t.onClick)),E("img",c)}function t1(e,t,n){var r;if(t.className){const o=((r=e.parseClassNameResponsive)==null?void 0:r.call(e,t.className,n))??e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("input",{key:n,className:t.className,...l,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.value})),onKeyDown:t.onKeyDown?c=>{c.key==="Enter"&&e.handleButtonClick(t.onKeyDown)}:void 0})}const s={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},i=e.getCommonProps(n,s,t);if(t.label){const o=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...o},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("input",{...i,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:l=>e.setSceneData(c=>({...c,[t.name||""]:l.target.value}))}))}return E("input",{key:n,...i,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:o=>e.setSceneData(l=>({...l,[t.name||""]:o.target.value}))})}function e1(e,t,n){const s=t.value?e.interpolateText(String(t.value)):e.sceneData[t.name||""]??"";return E("input",{key:n,type:"hidden",name:t.name,value:s})}function n1(e,t,n){var o;const s=()=>{var l;return[t.placeholder&&E("option",{key:"__placeholder",value:""},t.placeholder),...((l=t.options)==null?void 0:l.map(c=>E("option",{key:c.value,value:c.value},c.label)))||[]]};if(t.className){const l=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className),c=e.getCommonProps(n,l,t);return E("select",{key:n,className:t.className,...c,name:t.name,value:e.sceneData[t.name||""]??"",onChange:h=>e.setSceneData(a=>({...a,[t.name||""]:h.target.value}))},...s())}const i={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,cursor:"pointer",appearance:"none"},r=e.getCommonProps(n,i,t);if(t.label){const l=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...l},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("select",{...r,name:t.name,value:e.sceneData[t.name||""]??"",onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.value}))},...s()))}return E("select",{key:n,...r,name:t.name,value:e.sceneData[t.name||""]??"",onChange:l=>e.setSceneData(c=>({...c,[t.name||""]:l.target.value}))},...s())}function s1(e,t,n){const s=t.className||"flex items-center gap-3 cursor-pointer text-white",i=e.parseClassName(s),r="w-5 h-5 rounded border-gray-600 bg-gray-800 accent-primary",o=e.parseClassName(r),l=e.getCommonProps(n,i,t);return E("label",{key:n,className:s,...l},E("input",{type:"checkbox",className:r,style:o,checked:e.sceneData[t.name||""]||!1,onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.checked}))}),E("span",{},t.label||""))}function i1(e,t,n){const s={green:{bg:"#065f4620",color:"#22c55e",border:"#22c55e40"},blue:{bg:"#1e40af20",color:"#3b82f6",border:"#3b82f640"},red:{bg:"#7f1d1d20",color:"#ef4444",border:"#ef444440"},yellow:{bg:"#71370220",color:"#eab308",border:"#eab30840"},purple:{bg:"#581c8720",color:"#a855f7",border:"#a855f740"},orange:{bg:"#7c2d1220",color:"#f97316",border:"#f9731640"},gray:{bg:"#37415120",color:"#9ca3af",border:"#9ca3af40"},cyan:{bg:"#0e727020",color:"#06b6d4",border:"#06b6d440"},pink:{bg:"#83184420",color:"#ec4899",border:"#ec489940"}};let r=t.colorScheme||"gray";if(t.colorBy&&typeof t.colorBy=="object"){const a=(e.interpolateText(t.text||t.label||"")||"").trim().toLowerCase();t.colorBy[a]&&(r=t.colorBy[a])}const o=s[r]||s.gray,l=t.variant||"subtle";let c={display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,letterSpacing:"0.025em",textTransform:"uppercase",whiteSpace:"nowrap"};l==="solid"?(c.backgroundColor=o.color,c.color="#fff"):l==="outline"?(c.backgroundColor="transparent",c.color=o.color,c.border=`1px solid ${o.border||o.color}`):(c.backgroundColor=o.bg,c.color=o.color,t.bordered&&(c.border=`1px solid ${o.border||o.color}`)),t.pill&&(c.borderRadius="9999px"),t.className&&(c={...c,...e.parseClassName(t.className)});const h=e.getCommonProps(n,c,t);return E("span",{key:n,...h},e.interpolateText(t.text||t.label||""))}function r1(e,t,n){const s={display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",borderRadius:"9999px",fontSize:"12px",fontWeight:500,backgroundColor:t.bg||e.cfg.colors.surfaceHover,color:t.color||e.cfg.colors.textSecondary,...t.className?e.parseClassName(t.className):{}},i=e.getCommonProps(n,s,t);return E("span",{key:n,...i},e.interpolateText(t.text||t.label||""))}function o1(e,t,n){const i={sm:32,md:40,lg:48,xl:64}[t.size||"md"]||40,r=i*.4;if(t.src){const h={width:`${i}px`,height:`${i}px`,borderRadius:"50%",objectFit:"cover",...t.className?e.parseClassName(t.className):{}},a=e.getCommonProps(n,h,t);return E("img",{key:n,src:t.src,alt:t.alt||t.label||"",...a})}const o=t.initials||(t.label||t.text||"").split(" ").map(h=>h[0]).join("").slice(0,2).toUpperCase()||"?",l={width:`${i}px`,height:`${i}px`,borderRadius:"50%",backgroundColor:t.bg||e.cfg.colors.primary,color:t.color||e.cfg.colors.text,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${r}px`,fontWeight:600,flexShrink:0,...t.className?e.parseClassName(t.className):{}},c=e.getCommonProps(n,l,t);return E("div",{key:n,...c},o)}function a1(e,t,n){const s=t.progressValue??t.value??0,i=t.progressMax??100,r=(p,g)=>{if(typeof p=="string")return Number(e.interpolateText(p))||g;const d=Number(p);return Number.isFinite(d)?d:g},o=r(s,0),l=r(i,100),c=Math.min(100,Math.max(0,o/l*100)),a=o>l?e.cfg.colors.danger:t.color||e.cfg.colors.primary,u={width:"100%",display:"flex",flexDirection:"column",gap:"4px",...t.className?e.parseClassName(t.className):{}},f=e.getCommonProps(n,u,t);return E("div",{key:n,...f},(t.progressLabel||t.label)&&m.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:e.cfg.colors.textMuted}},E("span",null,e.interpolateText(t.progressLabel||t.label||"")),E("span",null,`${o}/${l}`)),m.createElement("div",{style:{width:"100%",height:"8px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden"}},E("div",{style:{width:`${Math.min(c,100)}%`,height:"100%",backgroundColor:a,borderRadius:"4px",transition:"width 0.3s ease"}})))}function l1(e,t,n){const s={position:"relative",width:"100%",...t.className?e.parseClassName(t.className):{}},i=e.getCommonProps(n,s,t);return E("div",{key:n,...i},E("span",{style:{position:"absolute",left:"12px",top:"50%",transform:"translateY(-50%)",color:e.cfg.colors.textPlaceholder,fontSize:"14px",pointerEvents:"none"}},e.renderIcon("search",14)),E("input",{type:"text",name:t.name||"search",placeholder:t.placeholder||"Search...",value:e.sceneData[t.name||"search"]??"",onChange:r=>{e.setSceneData(o=>({...o,[t.name||"search"]:r.target.value}))},style:{width:"100%",padding:"8px 12px 8px 36px",borderRadius:e.cfg.layout.borderRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",fontSize:e.cfg.typography.baseFontSize,transition:e.cfg.effects.transition}}))}function c1(e,t,n){const s=Array.isArray(t.breadcrumbItems)?t.breadcrumbItems:[],i={display:"flex",alignItems:"center",gap:"4px",fontSize:"14px",...t.className?e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return E("nav",{key:n,...r,"aria-label":"Breadcrumb"},s.map((o,l)=>{const c=l===s.length-1;return m.createElement(m.Fragment,{key:`${n}-bc-${l}`},m.createElement(c?"span":"a",{style:{color:c?e.cfg.colors.textSecondary:e.cfg.colors.textMuted,fontWeight:c?600:400,cursor:c?"default":"pointer",textDecoration:"none",transition:e.cfg.effects.transition},...!c&&o.href?{href:o.href}:{},...!c&&o.onClick?{onClick:()=>e.handleButtonClick(o.onClick,{})}:{}},o.label),!c&&E("span",{style:{color:e.cfg.colors.border,margin:"0 2px"}},"/"))}))}function h1(e,t,n){const s=Array.isArray(t.items)?t.items:[],[i,r]=m.useState(0),o=t.autoplay!==!1&&s.length>1,l=t.interval||4e3,c=t.effect==="fade"?"fade":"slide";m.useEffect(()=>{if(!o||s.length<2)return;const x=setInterval(()=>r(k=>(k+1)%s.length),l);return()=>clearInterval(x)},[o,l,s.length]);const h=x=>r((x%s.length+s.length)%s.length),a=t.showArrows!==!1&&s.length>1,u=t.showDots!==!1&&s.length>1,f={position:"relative",overflow:"hidden",...t.className?e.parseClassName(t.className):{}};t.aspectRatio&&(f.aspectRatio=t.aspectRatio),!t.aspectRatio&&!t.height&&(f.height="320px");const p=e.getCommonProps(n,f,t),g=x=>typeof x=="string"?{type:"text",text:x}:x&&x.image?{type:"image",src:x.image,alt:x.alt||"",title:x.title}:x,d=s.map((x,k)=>{const S=e.renderComponent({...g(x),key:void 0},k,`${n}-slide`),T={width:"100%",height:"100%",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"};return c==="fade"?(T.position="absolute",T.inset="0",T.opacity=k===i?1:0,T.transition="opacity .5s ease",T.pointerEvents=k===i?"auto":"none"):T.flexShrink=0,E("div",{key:`${n}-item-${k}`,style:T},S)}),w=c==="fade"?{position:"relative",width:"100%",height:"100%"}:{display:"flex",height:"100%",transition:"transform .5s ease",transform:`translateX(-${i*100}%)`},C={position:"absolute",top:"50%",transform:"translateY(-50%)",zIndex:2,width:"36px",height:"36px",borderRadius:"50%",border:"none",background:"rgba(0,0,0,0.45)",color:"#fff",fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};return E("div",{key:n,...p},E("div",{style:w},d),a&&E("div",{style:{...C,left:"8px"}},E("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>h(i-1),"aria-label":"Previous slide"},"<")),a&&E("div",{style:{...C,right:"8px"}},E("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>h(i+1),"aria-label":"Next slide"},">")),u&&E("div",{style:{position:"absolute",bottom:"10px",left:"50%",transform:"translateX(-50%)",display:"flex",gap:"6px",zIndex:2}},s.map((x,k)=>E("button",{key:`${n}-dot-${k}`,"aria-label":`Slide ${k+1}`,onClick:()=>h(k),style:{width:"10px",height:"10px",borderRadius:"50%",border:"none",cursor:"pointer",padding:0,background:k===i?"rgba(255,255,255,0.95)":"rgba(255,255,255,0.4)",transition:"background .3s ease"}}))))}function u1(e,t,n){const s=Array.isArray(t.items)?t.items:[],i=t.speed||20,r={overflow:"hidden",width:"100%",...t.className?e.parseClassName(t.className):{}},o=e.getCommonProps(n,r,t),l=c=>E("div",{key:c,style:{display:"inline-flex",alignItems:"center",gap:t.gap||"24px",paddingRight:t.gap||"24px",animation:`bf-marquee ${i}s linear infinite`,willChange:"transform",flexShrink:0}},s.map((h,a)=>{const u=typeof h=="string"?{type:"text",text:h}:h&&h.image?{type:"image",src:h.image,alt:h.alt||"",height:t.itemHeight||"48px"}:h;return e.renderComponent(u,a,`${c}-${n}-marq`)}));return E("div",{key:n,...o},E("div",{style:{display:"flex",width:"max-content"}},l("a"),l("b")))}function d1(e,t,n){const s=m.useRef(null),i=m.useRef(null),r=m.useRef(null),[o,l]=m.useState("idle"),[c,h]=m.useState(""),[a,u]=m.useState(!1),f=t.fieldName||"capture",p=t.captureMode==="qr",g=e.apiUrl||window.location.origin,d=t.uploadPath||"/api/files/upload",w=()=>{var H;(H=i.current)==null||H.getTracks().forEach(U=>U.stop()),i.current=null},C=async H=>{var V,D,j;const U=new FormData;U.append("file",H,`${f}-${Date.now()}.jpg`);const q=await fetch(new URL(d,g).toString(),{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`},body:U});if(!q.ok)throw new Error("Upload failed");const X=await q.json();return((V=X==null?void 0:X.file)==null?void 0:V.url)||((D=X==null?void 0:X.file)==null?void 0:D.publicUrl)||((j=X==null?void 0:X.file)==null?void 0:j.path)||(X==null?void 0:X.url)||(X==null?void 0:X.path)||""},x=async(H,U)=>{var q,X;if(o!=="done"){w();try{u(!0);const V=U||await C(H);e.setSceneData(D=>({...D,[f]:V})),h(V),l("done"),(q=e.showToast)==null||q.call(e,t.successMessage||(U?"Scanned!":"Captured & uploaded"),"success")}catch{l("error"),(X=e.showToast)==null||X.call(e,"Capture failed","error")}finally{u(!1)}}},k=()=>{var q;const H=s.current;if(!H||!H.videoWidth)return;const U=document.createElement("canvas");U.width=H.videoWidth,U.height=H.videoHeight,(q=U.getContext("2d"))==null||q.drawImage(H,0,0),U.toBlob(X=>X&&x(X),"image/jpeg",t.quality||.85)},S=async()=>{var H,U;try{const q=await navigator.mediaDevices.getUserMedia({video:{facingMode:t.facingMode||"user",...t.aspectRatio?{aspectRatio:Number(t.aspectRatio)}:{}},audio:!1});if(i.current=q,s.current&&(s.current.srcObject=q,await s.current.play().catch(()=>{})),l("running"),p){const V=window.BarcodeDetector;if(!V){l("error"),(H=e.showToast)==null||H.call(e,"QR scanning not supported in this browser","error");return}const D=new V;r.current=window.setInterval(async()=>{const j=s.current;if(!(!j||!j.videoWidth||o==="done"))try{const J=await D.detect(j);J!=null&&J.length&&x(new Blob,J[0].rawValue)}catch{}},400)}}catch{l("error"),(U=e.showToast)==null||U.call(e,"Camera access denied","error")}};m.useEffect(()=>(S(),()=>{r.current&&window.clearInterval(r.current),w()}),[]);const T={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",width:"100%",...t.className?e.parseClassName(t.className):{}},P=e.getCommonProps(n,T,t),I=E("video",{key:"cam-video",ref:s,autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a",display:p||o!=="done"?void 0:"none"}}),L=c?E("img",{key:"cam-result",src:c,alt:"captured",style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a"}}):null,O=E("div",{key:"cam-actions",style:{display:"flex",gap:"10px",flexWrap:"wrap",justifyContent:"center"}},o!=="done"?E("button",{key:"cam-capture",onClick:k,disabled:a||o!=="running",style:{padding:"10px 22px",borderRadius:"9999px",border:"none",cursor:a?"wait":"pointer",background:"#3B82F6",color:"#fff",fontWeight:600}},a?"Uploading...":p?t.captureLabel||"Scan QR":t.captureLabel||"Capture"):E("button",{key:"cam-retake",onClick:()=>{h(""),l("idle"),S()},style:{padding:"10px 22px",borderRadius:"9999px",border:"1px solid #94a3b8",cursor:"pointer",background:"transparent"}},"Retake"));return E("div",{key:n,...P},I,L,t.captureLabel===!1?null:O,o==="error"?E("p",{key:"cam-err",style:{color:"#EF4444",fontSize:"13px"}},"Camera unavailable — check permissions"):null)}function f1(e,t,n){var i;if(t.className){const r=((i=e.parseClassNameResponsive)==null?void 0:i.call(e,t.className,n))??e.parseClassName(t.className),o=e.getCommonProps(n,r,t);return E("div",{key:n,className:t.className,...o})}const s=e.getCommonProps(n,{height:t.h||t.height||"24px"},t);return E("div",{key:n,...s})}function m1(e,t,n){const s=t.className||"border-gray-700 my-4",i=e.parseClassName(s),r=e.getCommonProps(n,i,t);return E("hr",{key:n,className:s,...r})}function p1(e,t,n){var a;const s=t.loaderVariant||"spinner",i=t.rows||3,r=t.className?((a=e.parseClassNameResponsive)==null?void 0:a.call(e,t.className,n))??e.parseClassName(t.className):{};t.rawStyle&&Object.assign(r,t.rawStyle);const o=e.getCommonProps(n,r,t),l=`${e.scopeId}-${n}`,c=e.renderMode==="css-driven"?{"data-bf-r":l}:{};if(s==="skeleton"){const u=[];for(let f=0;f<i;f++){const p=t.width||(f===i-1?"60%":"100%");u.push(E("div",{key:f,className:"bf-loader-skeleton",style:{height:t.height||"16px",width:p,borderRadius:"6px",marginBottom:f<i-1?"12px":"0"}}))}return E("div",{key:n,className:t.className,style:r,...o,...c},...u)}if(s==="shimmer"){const u=[];for(let f=0;f<i;f++){const p=t.width||(f===i-1?"60%":"100%");u.push(E("div",{key:f,className:"bf-loader-shimmer",style:{height:t.height||"16px",width:p,borderRadius:"6px",marginBottom:f<i-1?"12px":"0"}}))}return E("div",{key:n,className:t.className,style:r,...o,...c},...u)}if(s==="dots"){const u=t.color||"currentColor";return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",gap:"6px",...r},...o,...c},[0,1,2].map(f=>E("div",{key:f,className:"bf-loader-dot",style:{width:t.size||"8px",height:t.size||"8px",borderRadius:"50%",backgroundColor:u,animationDelay:`${f*.16}s`}})))}if(s==="pulse")return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...r},...o,...c},E("div",{className:"bf-loader-pulse",style:{width:t.size||"32px",height:t.size||"32px",borderRadius:"50%",border:`3px solid ${t.color||"currentColor"}`}}));if(s==="progress")return E("div",{key:n,className:t.className,style:{width:"100%",...r},...o,...c},E("div",{style:{height:t.height||"4px",width:"100%",backgroundColor:"rgba(128,128,128,0.2)",borderRadius:"4px",overflow:"hidden"}},E("div",{className:"bf-loader-progress-bar",style:{height:"100%",width:"30%",backgroundColor:t.color||"currentColor",borderRadius:"4px"}})));const h=t.size||"24px";return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...r},...o,...c},E("div",{className:"bf-loader-spinner",style:{width:h,height:h,border:`3px solid ${t.color?t.color+"33":"rgba(128,128,128,0.2)"}`,borderTopColor:t.color||"currentColor",borderRadius:"50%"}}))}function g1(e,t,n){const s=t.rows||4;if(t.className){const o=e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("textarea",{key:n,className:t.className,...l,name:t.name,placeholder:t.placeholder,rows:s})}const i={width:"100%",padding:"0.75rem 1rem",borderRadius:e.cfg.components.inputRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,resize:"vertical",fontFamily:"inherit"},r=e.getCommonProps(n,i,t);if(t.label){const o=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...o},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("textarea",{...r,name:t.name,placeholder:t.placeholder,rows:s}))}return E("textarea",{key:n,...r,name:t.name,placeholder:t.placeholder,rows:s})}function y1(e,t,n){const s=t.icon||t.name||"",i=t.size||24,r=e.renderIcon(s,i);if(t.className){const o=e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("span",{key:n,className:t.className,...l},r)}return m.cloneElement(r,{key:n})}function b1(e,t,n){const s=t.metricSize||"md",i=s==="sm"?"1.25rem":s==="lg"?"2.5rem":"1.75rem",r=s==="sm"?"0.75rem":s==="lg"?"1rem":"0.875rem",o=t.color||e.cfg.colors.primary,l=t.trend==="up"?"↑":t.trend==="down"?"↓":"",c=t.trendColor||(t.trend==="up"?e.cfg.colors.success:t.trend==="down"?e.cfg.colors.danger:e.cfg.colors.textMuted),h={display:"flex",flexDirection:"column",gap:"2px",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},a=e.getCommonProps(n,h,t);return E("div",{key:n,...a},t.label&&E("span",{style:{fontSize:r,color:e.cfg.colors.textSecondary,fontWeight:500}},e.interpolateText(t.label)),m.createElement("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",marginTop:"4px"}},t.prefix&&E("span",{style:{fontSize:i,fontWeight:700,color:o}},t.prefix),E("span",{style:{fontSize:i,fontWeight:700,color:e.cfg.colors.text}},typeof t.value=="number"?t.value.toLocaleString():e.interpolateText(String(t.value??""))),t.suffix&&E("span",{style:{fontSize:i,fontWeight:700,color:o}},t.suffix),t.delta&&E("span",{style:{fontSize:"0.75rem",fontWeight:600,color:c,marginLeft:"4px"}},`${l} ${t.delta}`)))}function v1(e,t,n){const s=t.chartData||t.data||[];if(!Array.isArray(s)||s.length===0)return null;const i=t.height||200,r=t.barColor||e.cfg.colors.primary,o=t.showValues!==!1,l=t.horizontal===!0,c=t.maxValue||Math.max(...s.map(f=>f.value),1),h=l?8:Math.max(4,Math.min(20,300/s.length)),a={width:"100%",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.title?{}:{},...t.className?e.parseClassName(t.className):{}},u=e.getCommonProps(n,a,t);return E("div",{key:n,...u},t.title&&E("div",{style:{fontSize:"0.875rem",fontWeight:600,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem",textAlign:"center"}},t.title),E("div",{style:{display:"flex",flexDirection:l?"column":"row",alignItems:l?"stretch":"flex-end",justifyContent:"center",gap:`${h}px`,height:l?void 0:`${i}px`,width:l?"100%":void 0,minHeight:l?void 0:`${i}px`,padding:"4px 0"}},...s.map((f,p)=>{const g=c>0?f.value/c*100:0,d=f.color||r;return l?E("div",{key:p,style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"}},E("span",{style:{fontSize:"0.75rem",color:e.cfg.colors.textSecondary,minWidth:"60px",textAlign:"right",flexShrink:0}},f.label),E("div",{style:{flex:1,height:"20px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden",position:"relative"}},E("div",{style:{width:`${g}%`,height:"100%",backgroundColor:d,borderRadius:"4px",transition:"width 0.5s ease"}})),o&&E("span",{style:{fontSize:"0.7rem",color:e.cfg.colors.textMuted,minWidth:"32px",fontVariantNumeric:"tabular-nums"}},typeof f.value=="number"?f.value.toLocaleString():String(f.value))):E("div",{key:p,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",flex:1,height:"100%",maxWidth:"60px"}},o&&E("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textMuted,marginBottom:"2px",fontVariantNumeric:"tabular-nums"}},typeof f.value=="number"?f.value.toLocaleString():String(f.value)),E("div",{style:{width:"100%",height:`${g}%`,backgroundColor:d,borderRadius:"4px 4px 0 0",transition:"height 0.5s ease",minHeight:g>0?"4px":"0px"}}),E("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textSecondary,marginTop:"4px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"}},f.label))})))}function Go(e,t,n,s=!1,i=!1){const r=Array.isArray(t.chartData)?t.chartData:[];if(r.length===0)return null;const o=r.flatMap(k=>i?[k.low,k.high]:[k.value]).map(Number).filter(Number.isFinite);if(o.length===0)return null;const l=Math.min(...o),h=Math.max(...o)-l||1,a=Number(t.height)||220,u=640,f=k=>r.length===1?u/2:k/(r.length-1)*u,p=k=>a-(k-l)/h*a,g=r.map((k,S)=>`${f(S)},${p(Number(k.value))}`).join(" "),d=t.lineColor||e.cfg.colors.accent,w=t.fillColor||`${d}33`,C={width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},x=i?r.map((k,S)=>{const T=Number(k.open),P=Number(k.close),I=Number(k.high),L=Number(k.low),O=P>=T;return E("div",{key:S,style:{flex:1,height:"100%",position:"relative"}},E("div",{style:{position:"absolute",left:"50%",top:`${p(I)}px`,height:`${Math.max(1,p(L)-p(I))}px`,borderLeft:`1px solid ${O?"#22c55e":"#ef4444"}`}}),E("div",{style:{position:"absolute",left:"25%",right:"25%",top:`${p(Math.max(T,P))}px`,height:`${Math.max(3,Math.abs(p(P)-p(T)))}px`,background:O?"#22c55e":"#ef4444",borderRadius:"2px"}}))}):m.createElement("svg",{viewBox:`0 0 ${u} ${a}`,preserveAspectRatio:"none",style:{width:"100%",height:a}},t.showGrid!==!1&&[25,50,75].map(k=>m.createElement("line",{key:k,x1:0,x2:u,y1:a*k/100,y2:a*k/100,stroke:e.cfg.colors.borderSubtle,strokeDasharray:"3 4"})),s&&m.createElement("polygon",{points:`0,${a} ${g} ${u},${a}`,fill:w}),m.createElement("polyline",{points:g,fill:"none",stroke:d,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round"}));return E("div",{key:n,style:e.getCommonProps(n,C,t)},t.title&&E("div",{style:{color:e.cfg.colors.textSecondary,fontWeight:600,marginBottom:"0.75rem"}},t.title),E("div",{style:{display:"flex",alignItems:"stretch",gap:i?"4px":void 0,height:a}},x),E("div",{style:{display:"flex",justifyContent:"space-between",color:e.cfg.colors.textMuted,fontSize:"0.7rem",marginTop:"4px"}},...r.map((k,S)=>E("span",{key:S},k.label||""))))}function x1(e,t,n){const s=Array.isArray(t.chartData)?t.chartData[0]||{}:{},i=t.ticker||s.ticker||s.symbol||"EUR/USD",r=t.bid??s.bid??s.price,o=t.ask??s.ask,l=t.change??s.change,c=Number(l),h=Number.isFinite(c)&&c>=0,a=e.getCommonProps(n,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",width:"100%",padding:"0.9rem 1rem",backgroundColor:e.cfg.colors.surface,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:e.cfg.layout.borderRadiusLg,...t.className?e.parseClassName(t.className):{}},t);return E("div",{key:n,...a},E("div",{},E("div",{style:{color:e.cfg.colors.text,fontWeight:700}},i),t.label&&E("div",{style:{color:e.cfg.colors.textMuted,fontSize:"0.75rem"}},t.label)),E("div",{style:{display:"flex",gap:"1rem",alignItems:"baseline",fontVariantNumeric:"tabular-nums"}},r!=null&&E("span",{style:{color:e.cfg.colors.text,fontWeight:700}},String(r)),o!=null&&E("span",{style:{color:e.cfg.colors.textSecondary}},String(o)),l!=null&&E("span",{style:{color:h?"#22c55e":"#ef4444",fontSize:"0.8rem",fontWeight:600}},`${h?"+":""}${l}`)))}function w1({api:e,c:t,componentKey:n}){var w,C,x,k;const s=m.useRef(null),i=m.useRef(null),r=m.useRef(null),[o,l]=m.useState(null),c=m.useRef(null),[h,a]=m.useState(()=>Array.isArray(t.chartData)?t.chartData:[]);m.useEffect(()=>{Array.isArray(t.chartData)&&a(t.chartData)},[t.chartData]);const u=e.interpolateText(((w=t.realtime)==null?void 0:w.channel)||""),f=e.interpolateText(((C=t.timeRange)==null?void 0:C.from)||""),p=e.interpolateText(((x=t.timeRange)==null?void 0:x.to)||""),g=Array.isArray(t.timeframes)?t.timeframes:[];m.useEffect(()=>{var I,L;const S=e.sdk;if(!(((I=t.realtime)==null?void 0:I.mode)==="ws"&&e.isAuthenticated&&u&&((L=S==null?void 0:S.client)==null?void 0:L.createWebSocket)))return;const P=S.client.createWebSocket(u);return P.onmessage=O=>{var H;try{const U=typeof O.data=="string"?JSON.parse(O.data):O.data,q=(U==null?void 0:U.tick)||((H=U==null?void 0:U.data)==null?void 0:H.tick)||(U==null?void 0:U.data)||U,X=Number((q==null?void 0:q.quote)??(q==null?void 0:q.price)??(q==null?void 0:q.close));if(!Number.isFinite(X))return;const V=Number((q==null?void 0:q.epoch)??(q==null?void 0:q.timestamp)??Date.now()/1e3),D=Math.floor(V/60)*60;a(j=>{const J=j[j.length-1];if((J==null?void 0:J.time)===D)return[...j.slice(0,-1),{...J,high:Math.max(Number(J.high),X),low:Math.min(Number(J.low),X),close:X}];const nt=Number((J==null?void 0:J.close)??X);return[...j.slice(-99),{time:D,open:nt,high:X,low:X,close:X}]})}catch{}},()=>{var O;return(O=P.close)==null?void 0:O.call(P)}},[e.isAuthenticated,(k=t.realtime)==null?void 0:k.mode,u]);const d=m.useMemo(()=>h.map((S,T)=>{const P=S.time||S.timestamp;return{time:typeof P=="string"&&P.includes("T")?Math.floor(new Date(P).getTime()/1e3):P||`2024-01-${String(T+1).padStart(2,"0")}`,...t.chartType==="candlestick"?{open:Number(S.open),high:Number(S.high),low:Number(S.low),close:Number(S.close)}:{value:Number(S.value??S.close)}}}),[t.chartType,h]);return c.current=d[d.length-1],m.useEffect(()=>{const S=s.current;if(!S)return;const T=Tw(S,{autoSize:!0,height:Number(t.height)||280,layout:{background:{color:"transparent"},textColor:e.cfg.colors.textSecondary},grid:{vertLines:{color:e.cfg.colors.borderSubtle},horzLines:{color:e.cfg.colors.borderSubtle}},rightPriceScale:{borderColor:e.cfg.colors.borderSubtle},timeScale:{borderColor:e.cfg.colors.borderSubtle,timeVisible:!0}}),P=t.chartType||"candlestick",I=P==="line"?T.addSeries(Iw,{color:t.lineColor||e.cfg.colors.accent}):P==="area"?T.addSeries(jw,{lineColor:t.lineColor||e.cfg.colors.accent,topColor:t.fillColor||`${e.cfg.colors.accent}66`,bottomColor:"transparent"}):T.addSeries(qw,{upColor:"#22c55e",downColor:"#ef4444",borderVisible:!1,wickUpColor:"#22c55e",wickDownColor:"#ef4444"});return r.current=T,i.current=I,()=>{i.current=null,r.current=null,T.remove()}},[e.cfg.colors.accent,e.cfg.colors.borderSubtle,e.cfg.colors.textSecondary,t.chartType,t.height,t.lineColor,t.fillColor]),m.useEffect(()=>{var S,T;!i.current||d.length===0||(i.current.setData(d),f&&p?(S=r.current)==null||S.timeScale().setVisibleRange({from:f,to:p}):(T=r.current)!=null&&T.timeScale().getVisibleLogicalRange()||r.current.timeScale().fitContent())},[d,f,p]),m.useEffect(()=>{if(!o||!r.current||!c.current)return;const S={"1H":3600,"4H":14400,"1D":86400,"1W":604800}[o],T=Number(c.current.time);S&&Number.isFinite(T)&&r.current.timeScale().setVisibleRange({from:T-S,to:T})},[o]),E("div",{key:n,style:{width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}}},g.length>0&&E("div",{style:{display:"flex",gap:"0.35rem",marginBottom:"0.5rem"}},...g.map(S=>E("button",{key:S,type:"button",onClick:()=>l(S),style:{padding:"0.3rem 0.6rem",border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:4,color:e.cfg.colors.text,background:o===S?e.cfg.colors.surfaceHover:"transparent",cursor:"pointer"}},S))),E("div",{ref:s,style:{width:"100%",height:Number(t.height)||280}}))}function S1(e,t,n){return m.createElement(w1,{api:e,c:t,componentKey:n})}function C1(e,t,n){const s=t.json||t.data||t.diagram||{},i=e.getCommonProps(n,{display:"flex",flexDirection:"column",minHeight:"300px"},t);return E("div",{key:n,className:t.className,...i},m.createElement("pre",{style:{fontSize:"12px",whiteSpace:"pre-wrap",margin:0}},typeof s=="string"?s:JSON.stringify(s,null,2)))}function k1({api:e,c:t,componentKey:n}){const s=t.data||t.json||t.diagram||{},{_config:i,...r}=s||{},o=Object.keys(r).length?r:s,{nodes:l,edges:c}=m.useMemo(()=>fc.createFlowDiagram(o),[o]),[h,a]=m.useState("LR"),u=e.cfg.fullscreen===!0,f=t.height||(u?"100%":320),p=e.getCommonProps(n,{width:"100%",height:f,...u?{minHeight:0}:{}},t);return E("div",{key:n,className:t.className,...p},m.createElement(fc.FlowDiagram,{nodes:l,edges:c,config:{direction:h,layout:(i==null?void 0:i.layout)||"dagre",colorMode:(i==null?void 0:i.colorMode)||(e.cfg.colorMode==="dark"?"dark":"light"),backgroundPattern:(i==null?void 0:i.backgroundPattern)||"dot"},callbacks:{onDirectionChange:g=>a(g)},showBottomBar:(i==null?void 0:i.showBottomBar)||!1,style:{width:"100%",height:"100%"}}))}function M1(e,t,n){return m.createElement(k1,{api:e,c:t,componentKey:n})}function E1(e,t,n){var s;if(t.className){const i=((s=e.parseClassNameResponsive)==null?void 0:s.call(e,t.className,n))??e.parseClassName(t.className);i.display==null&&(i.display="flex"),i.flexDirection==null&&(i.flexDirection=/(^|\s)flex(\s|$)/.test(t.className||"")||t.layout==="row"?"row":"column");const r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,className:t.className,...r},(Array.isArray(t.children)?t.children:[]).map((o,l)=>e.renderComponent(o,l,n)))}return null}const T1=m.memo(({api:e,field:t,fieldName:n,value:s,onChange:i})=>{m.useEffect(()=>{s!==void 0&&s!==""&&i&&i(s)},[]);const r=m.useRef(null),[o,l]=m.useState(!1),c=m.useRef(null),h=m.useRef(null),[a,u]=m.useState(!1),[f,p]=m.useState(""),[g,d]=m.useState(!1),w=t.html!==!1,C=x=>w?x:x.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\n/g,"<br>");return m.useEffect(()=>{r.current&&!r.current.innerHTML&&(r.current.innerHTML=C(s))},[]),m.useEffect(()=>{r.current&&document.activeElement!==r.current&&r.current.innerHTML!==s&&(r.current.innerHTML=C(s))},[s]),m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,m.createElement("div",{style:{border:`1px solid ${o?e.cfg.colors.primary:e.cfg.colors.border}`,borderRadius:e.cfg.components.inputRadius,overflow:"hidden",transition:"border-color 0.2s",position:"relative"}},m.createElement("div",{style:{display:"flex",gap:"4px",padding:"6px 8px",borderBottom:`1px solid ${e.cfg.colors.border}`,backgroundColor:e.cfg.colors.surface}},...[{cmd:"bold",label:"B"},{cmd:"italic",label:"I"},{cmd:"underline",label:"U"}].map(x=>E("button",{key:x.cmd,type:"button",onMouseDown:k=>{var S;k.preventDefault(),document.execCommand(x.cmd,!1),(S=r.current)==null||S.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontWeight:600,fontSize:"13px"},onMouseEnter:k=>k.target.style.borderColor=e.cfg.colors.border,onMouseLeave:k=>k.target.style.borderColor="transparent"},x.label)),E("span",{key:"spacer",style:{flex:1}}),E("button",{key:"list-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),document.execCommand("insertUnorderedList",!1),(k=r.current)==null||k.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},"☰"),E("span",{key:"divider",style:{width:"1px",height:"16px",backgroundColor:e.cfg.colors.border,margin:"0 4px",alignSelf:"center"}}),E("button",{key:"img-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),(k=c.current)==null||k.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("image",14)),E("button",{key:"att-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),(k=h.current)==null||k.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("paperclip",14)),E("button",{key:"ai-btn",type:"button",onMouseDown:x=>{x.preventDefault(),u(!a)},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:a?e.cfg.colors.border:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("sparkles",14))),E("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onInput:x=>i(x.currentTarget.innerHTML),onFocus:()=>l(!0),onBlur:()=>l(!1),style:{minHeight:(t.rows||10)*20+"px",padding:"0.75rem 1rem",backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,outline:"none",fontSize:"0.875rem",lineHeight:"1.6"}}),t.expandAction?m.createElement("button",{type:"button",key:"expand",style:{position:"absolute",bottom:"6px",left:"6px",background:"rgba(0,0,0,0.55)",border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"3px 5px",display:"flex",alignItems:"center",justifyContent:"center",opacity:.5,transition:"opacity 0.2s",zIndex:1},onMouseEnter:x=>{x.currentTarget.style.opacity="0.85"},onMouseLeave:x=>{x.currentTarget.style.opacity="0.5"},onClick:x=>{x.preventDefault(),x.stopPropagation(),e.handleButtonClick(t.expandAction,{})}},e.renderIcon("maximize-2",13)):null,E("input",{key:"img-input",ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:async x=>{var S,T,P,I,L,O;const k=(S=x.target.files)==null?void 0:S[0];if(k){try{const H=(T=e.showToast)==null?void 0:T.call(e,"Uploading image (0%)…","success",0),U=e.uploadFile?await e.uploadFile(k,t.upload,q=>{var X;return(X=H==null?void 0:H.update)==null?void 0:X.call(H,`Uploading image (${q}%)`)}):"";if((P=H==null?void 0:H.dismiss)==null||P.call(H),!U)throw Error();(I=r.current)==null||I.focus(),document.execCommand("insertImage",!1,U),i(((L=r.current)==null?void 0:L.innerHTML)||"")}catch{(O=e.showToast)==null||O.call(e,"Failed to upload image","error")}x.target.value=""}}}),E("input",{key:"att-input",ref:h,type:"file",multiple:!0,style:{display:"none"},onChange:async x=>{var I,L,O,H,U;const k=Array.from(x.target.files||[]);x.target.value="";const S=[];let T=0;const P=(I=e.showToast)==null?void 0:I.call(e,`Uploading 0/${k.length}…`,"success",0);for(const q of k){try{const X=e.uploadFile?await e.uploadFile(q,t.upload,V=>{var D;return(D=P==null?void 0:P.update)==null?void 0:D.call(P,`Uploading ${q.name} (${V}%)`)}):"";if(!X)throw Error();S.push(`<a href="${X}">${q.name}</a>`)}catch{(L=e.showToast)==null||L.call(e,`Failed to upload ${q.name}`,"error")}T++,(O=P==null?void 0:P.update)==null||O.call(P,`Uploading ${T}/${k.length}…`)}if((H=P==null?void 0:P.dismiss)==null||H.call(P),S.length>0&&r.current){r.current.focus();const q=window.getSelection();if(q){q.removeAllRanges();const X=document.createRange();X.selectNodeContents(r.current),X.collapse(!1),q.addRange(X)}document.execCommand("insertHTML",!1,`<br><br>${S.join(", ")}`),i(((U=r.current)==null?void 0:U.innerHTML)||"")}}}),a?E("div",{key:"ai-popup",style:{position:"absolute",bottom:"100%",left:"8px",right:"8px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",padding:"12px",zIndex:10,boxShadow:"0 -4px 24px rgba(0,0,0,0.4)"}},E("textarea",{value:f,onChange:x=>p(x.target.value),placeholder:"Ask AI to draft a reply...",rows:3,style:{width:"100%",padding:"8px 12px",borderRadius:"4px",border:`1px solid ${e.cfg.colors.borderSubtle}`,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,fontSize:"13px",outline:"none",fontFamily:"inherit",resize:"none",boxSizing:"border-box"}}),E("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"8px"}},E("button",{type:"button",onClick:()=>{u(!1),p("")},style:{padding:"6px 14px",borderRadius:"6px",border:`1px solid ${e.cfg.colors.borderSubtle}`,cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textMuted,fontSize:"12px",fontFamily:"inherit"}},"Cancel"),E("button",{type:"button",disabled:g||!f.trim(),onClick:async()=>{var x,k,S,T;if(!(!f.trim()||g)){d(!0);try{const P=((x=r.current)==null?void 0:x.innerHTML)||"",I=await fetch("/api/tenant/email/ai/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f,context:P})});if(!I.ok)throw Error();const L=await I.json(),O=L.response||L.text||L.content||"";(k=r.current)==null||k.focus(),document.execCommand("insertText",!1,O),i(((S=r.current)==null?void 0:S.innerHTML)||""),u(!1),p("")}catch{(T=e.showToast)==null||T.call(e,"AI request failed","error")}d(!1)}},style:{padding:"6px 14px",borderRadius:"6px",border:"none",cursor:g||!f.trim()?"not-allowed":"pointer",backgroundColor:g||!f.trim()?e.cfg.colors.surfaceHover:e.cfg.colors.background,color:g||!f.trim()?e.cfg.colors.textSecondary:e.cfg.colors.text,fontSize:"12px",fontWeight:600,fontFamily:"inherit"}},g?"Thinking...":"Generate"))):null))}),A1=m.memo(({api:e,c:t,componentKey:n})=>{const[s,i]=m.useState(!1),r=m.useRef(null),[o,l]=m.useState([]),c=t.name?`bf_persist_${t.name}`:null;m.useEffect(()=>{t.dataSource&&(async()=>{var u;try{const f=e.interpolateText(t.dataSource),p=(u=e.selectDynamicOptions)==null?void 0:u[f];if(p&&p.length>0){l(p);return}En[f]||(En[f]=(async()=>{var d;try{const w=await fetch(f,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!w.ok)return[];const C=await w.json(),x=t.dataField||"configs",k=t.optionLabel||"label",S=t.optionValue||"value",T=C[x]||C.data||C,P=Array.isArray(T)?T.map(I=>({label:I[k]||I.name||I.label,value:I[S]||I.id||I.name||I.label})):[];return(d=e.setSelectDynamicOptions)==null||d.call(e,I=>({...I,[f]:P})),P}catch{return delete En[f],[]}})());const g=await En[f];g.length>0&&l(g)}catch{}})()},[t.dataSource]),m.useEffect(()=>{if(c&&t.name&&!e.sceneData[t.name]){const f=localStorage.getItem(c);f&&e.setSceneData(p=>({...p,[t.name]:f}))}},[c,t.name,e.sceneData[t.name]]),m.useEffect(()=>{if(!s)return;const u=p=>{r.current&&!r.current.contains(p.target)&&i(!1)},f=setTimeout(()=>{document.addEventListener("mousedown",u)},0);return()=>{clearTimeout(f),document.removeEventListener("mousedown",u)}},[s]);const h=t.variant==="selector",a=Array.isArray(t.items)?t.items:o;if(h){const u=t.name&&(e.sceneData[t.name||""]||c&&localStorage.getItem(c))||"",f=u||t.placeholder||"Select...";return E("div",{ref:r,style:{position:"relative",display:"inline-flex"}},m.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:t.fontSize||"1rem",fontWeight:t.fontWeight||600,color:t.color||e.cfg.colors.text,padding:"2px 0",outline:"none",lineHeight:"1.5"},onClick:p=>{p.preventDefault(),i(!s)}},E("span",{key:"text"},f),E("span",{key:"caret",style:{display:"flex",alignItems:"center",opacity:.6,marginLeft:"2px"}},e.renderIcon("chevron-down",14))),s?m.createElement("div",{style:{position:"absolute",top:"100%",left:"0",marginTop:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden",minWidth:"200px"}},...a.map((p,g)=>m.createElement("button",{key:g,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none",whiteSpace:"nowrap"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent"},onClick:d=>{d.preventDefault(),d.stopPropagation(),i(!1),t.name&&p.value!==u&&e.setSceneData(w=>({...w,[t.name]:p.value}))}},p.label||""))):null)}return m.createElement("div",{ref:r,style:{position:"relative",display:"flex",width:"100%"}},(()=>{var p;const u=!!((p=e.buttonLoading)!=null&&p[n]),f=[];return u?f.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):t.icon&&f.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(t.icon,t.iconSize||16))),f.push(E("span",{key:"text",style:{lineHeight:"1"}},t.text||"Button")),m.createElement("button",{type:"button",style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontSize:"0.875rem",fontWeight:600,fontFamily:"inherit",lineHeight:"1.25rem",transition:"all 0.15s ease",outline:"none"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=e.cfg.colors.border,g.currentTarget.style.color=e.cfg.colorMode==="light"?"#111827":e.cfg.colors.text},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",g.currentTarget.style.color=e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary},onClick:g=>{if(g.preventDefault(),a.length>0&&a[0].onClick){const d=()=>e.handleButtonClick(a[0].onClick,{onSuccess:a[0].onSuccess,onError:a[0].onError},{feedback:a[0].feedback,optimistic:a[0].optimistic,payload:a[0].payload});(e.withLoading?e.withLoading(n,d):d()).catch(()=>{})}}},...f)})(),a.length>0?m.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0.75rem 0.5rem",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,borderLeft:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s ease",outline:"none"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor=e.cfg.colors.border,u.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.color=e.cfg.colors.textSecondary},onClick:u=>{u.preventDefault(),u.stopPropagation(),i(!s)}},e.renderIcon("chevron-down",16)):null,s?m.createElement("div",{style:{position:"absolute",bottom:"100%",left:"0",right:"0",marginBottom:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 -8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden"}},...a.map((u,f)=>{var w;const p=`${n}-item-${f}`,g=!!((w=e.buttonLoading)!=null&&w[p]),d=[];return g?d.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):u.icon&&d.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"8px"}},e.renderIcon(u.icon,14))),d.push(u.label||""),m.createElement("button",{key:f,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},onClick:C=>{if(C.preventDefault(),C.stopPropagation(),!u.onClick)return;const x=u.loading==="self"?p:n;u.loading==="self"?i(!0):i(!1);const k=()=>e.handleButtonClick(u.onClick,{onSuccess:u.onSuccess,onError:u.onError},{feedback:u.feedback,optimistic:u.optimistic,payload:u.payload});(e.withLoading?e.withLoading(x,k):k()).finally(()=>{u.loading==="self"&&i(!1)}).catch(()=>{})}},...d)})):null)});function R1(e,t,n){return m.createElement(A1,{api:e,c:t,componentKey:n})}function P1(e,t,n){var c,h;const s=t.widgetId;if(!s)return null;const r=(e.widgets||[]).find(a=>a.id===s);if(!r||!Array.isArray(r.components))return Br(`[renderer] widget "${s}" not found`),null;if(e.widgetStack&&e.widgetStack.includes(s))return Br(`[renderer] circular widget reference "${s}"`),null;(c=e.widgetStack)==null||c.push(s);const o=t.props||{},l=Ea(r.components,o).map((a,u)=>e.renderComponent(a,u,`${n}-${s}`));return(h=e.widgetStack)==null||h.pop(),m.createElement(m.Fragment,null,...l)}function Ea(e,t){if(!t||Object.keys(t).length===0)return e;if(Array.isArray(e))return e.map(n=>Ea(n,t));if(e&&typeof e=="object"){const n={};for(const[s,i]of Object.entries(e))typeof i=="string"&&i.includes("{{")?n[s]=i.replace(/\{\{\s*props\.([\w.]+)\s*\}\}/g,(r,o)=>{let l=t;for(const c of o.split("."))l=l==null?void 0:l[c];return l==null?"":String(l)}):n[s]=Ea(i,t);return n}return e}const lm=m.memo(({api:e,c:t,componentKey:n})=>{const[s,i]=m.useState(!1),[r,o]=m.useState(""),l=m.useRef(null),c=m.useMemo(()=>(Array.isArray(t.options)?t.options:[]).map(d=>typeof d=="string"?{label:d,value:d}:{label:d.label||d.value,value:d.value||d.label}),[t.options]),h=e.sceneData[t.name||""]??"",a=c.find(g=>g.value===h),u=m.useMemo(()=>{if(!r)return c;const g=r.toLowerCase();return c.filter(d=>d.label.toLowerCase().includes(g))},[c,r]),f=t.custom&&r&&!c.find(g=>g.value===r||g.label===r);m.useEffect(()=>{if(!s){o("");return}const g=d=>{l.current&&!l.current.contains(d.target)&&i(!1)};return setTimeout(()=>document.addEventListener("mousedown",g),0),()=>document.removeEventListener("mousedown",g)},[s]);const p=g=>{e.setSceneData(d=>({...d,[t.name||""]:g})),i(!1)};return E("div",{key:n,ref:l,style:{position:"relative",width:"100%"}},t.label&&E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("button",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 8px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontSize:"14px",textAlign:"left",gap:"8px"},onClick:()=>i(!s)},E("span",null,a?a.label:t.placeholder||"Select..."),E("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},E("path",{d:"m6 9 6 6 6-6"}))),s&&E("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,marginTop:"4px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:e.cfg.colors.surface,overflow:"hidden",maxHeight:"260px",display:"flex",flexDirection:"column"}},t.searchable!==!1&&E("input",{style:{width:"100%",padding:"8px",border:"none",borderBottom:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.text,outline:"none",fontSize:"13px"},placeholder:"Search...",value:r,onChange:g=>{o(g.target.value),g.stopPropagation()},onClick:g=>g.stopPropagation()}),E("div",{style:{overflow:"auto",flex:1}},u.map(g=>E("button",{key:g.value,style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",background:g.value===h?"rgba(59,130,246,0.2)":"transparent",color:g.value===h?e.cfg.colors.primary:e.cfg.colors.text,cursor:"pointer",fontSize:"13px"},onMouseEnter:d=>{d.currentTarget.style.background=e.cfg.colors.surfaceHover},onMouseLeave:d=>{d.currentTarget.style.background=g.value===h?"rgba(59,130,246,0.2)":"transparent"},onClick:()=>p(g.value)},g.label)),f&&E("button",{style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",borderTop:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.primary,cursor:"pointer",fontSize:"13px",fontStyle:"italic"},onClick:()=>p(r)},`+ Add "${r}"`))))});function _1(e,t,n){return m.createElement(lm,{api:e,c:t,componentKey:n})}const En={},$1=m.memo(({api:e,field:t,fieldName:n,fieldKey:s,fieldStyle:i,fieldWrapperStyle:r})=>{const[o,l]=m.useState([]);m.useEffect(()=>{t.dataSource&&(async()=>{var a;try{const u=e.interpolateText(t.dataSource),f=(a=e.selectDynamicOptions)==null?void 0:a[u];if(f&&f.length>0){l(f);return}En[u]||(En[u]=(async()=>{var g;try{const d=await fetch(u,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!d.ok)return[];const w=await d.json(),C=t.dataField||"configs",x=t.optionLabel||"label",k=t.optionValue||"value",S=w[C]||w.data||w,T=Array.isArray(S)?S.map(P=>({label:P[x]||P.name||P.label,value:P[k]||P.id||P.name||P.label})):[];return(g=e.setSelectDynamicOptions)==null||g.call(e,P=>({...P,[u]:T})),T}catch{return delete En[u],[]}})());const p=await En[u];p.length>0&&l(p)}catch{}})()},[t.dataSource]);const c=o.length>0?o:Array.isArray(t.options)?t.options:[],h=t.placeholder||t.label||"Select...";return m.createElement("div",{key:s,style:r||{width:"100%"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,E("select",{name:n,value:e.sceneData[n]??"",required:t.required,className:t.className,style:{...i,fontSize:"0.875rem"},size:"md",onChange:a=>e.setSceneData(u=>({...u,[n]:a.target.value}))},E("option",{key:"__placeholder",value:"",disabled:!0,hidden:!0},h),c.map((a,u)=>E("option",{key:u,value:typeof a=="string"?a:a.value},typeof a=="string"?a:a.label))))});function N1(e,t,n){var c;const s=t.className||"",i=((c=e.parseClassNameResponsive)==null?void 0:c.call(e,s,n))??e.parseClassName(s),r=e.getCommonProps(n,i,t),o=Array.isArray(t.fields)?t.fields:[],l=t.submitButton;return t.collection&&e.fetchEntitySchema?m.createElement(I1,{api:e,c:t,componentKey:n,formClassName:s,parsedStyle:i,formProps:r,fields:o,submitBtn:l}):cm(e,t,n,s,i,r,o,l)}function I1({api:e,c:t,componentKey:n,formClassName:s,parsedStyle:i,formProps:r,fields:o,submitBtn:l}){const[c,h]=m.useState(o),[a,u]=m.useState(!0);return m.useEffect(()=>{if(!e.fetchEntitySchema){u(!1);return}e.fetchEntitySchema(t.collection).then(f=>{if(!Array.isArray(f==null?void 0:f.fields)){u(!1);return}const p=new Map(f.fields.map(d=>[d.name,d])),g=o.map(d=>{var C;const w=p.get(d.name||((C=d.label)==null?void 0:C.toLowerCase()));return w?{...d,required:d.required??w.required,validation:d.validation??(w.validation?{...w.validation}:void 0),placeholder:d.placeholder??w.placeholder}:d});h(g),u(!1)}).catch(()=>u(!1))},[t.collection]),a?E("div",{key:n,style:{padding:"1rem",textAlign:"center",color:e.cfg.colors.textMuted,fontSize:"0.8rem"}},"Loading fields..."):cm(e,t,n,s,i,r,c,l)}const D1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,inputType:o,label:l,fieldStyle:c,onKeyDown:h}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const a=m.useRef(s);a.current=s;const u=m.useRef(c);u.current=c;const f=m.useCallback(g=>{a.current(g.target.value)},[]),p=m.createElement("input",{name:t,placeholder:i,required:r,type:o||"text",value:n??"",onChange:f,onKeyDown:h?g=>{g.key==="Enter"&&h()}:void 0,style:u.current});return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:c.color,marginBottom:"0.75rem"}},l),p):p}),L1=m.memo(function({api:t,field:n,fieldName:s,label:i,fieldStyle:r}){const o=m.useRef(null),[l,c]=m.useState(!1),h=t.sceneData[s]||"",a=t.sceneData[s+"_name"]||"",u=async f=>{var g,d,w,C;const p=(g=f.target.files)==null?void 0:g[0];if(f.target.value="",!!p){c(!0);try{const x=(d=t.showToast)==null?void 0:d.call(t,"Uploading test case (0%)…","success",0),k=t.uploadFile?await t.uploadFile(p,n.upload,S=>{var T;return(T=x==null?void 0:x.update)==null?void 0:T.call(x,`Uploading test case (${S}%)`)}):"";if((w=x==null?void 0:x.dismiss)==null||w.call(x),!k)throw new Error;t.setSceneData(S=>({...S,[s]:k,[s+"_name"]:p.name}))}catch{(C=t.showToast)==null||C.call(t,"Upload failed","error")}finally{c(!1)}}};return m.createElement("div",{style:{width:"100%"}},i&&E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:t.cfg.colors.textSecondary,marginBottom:"0.75rem"}},i),h?m.createElement("div",{style:{...r,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}},E("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"📎 "+(a||"Test case uploaded")),E("button",{type:"button",style:{background:"none",border:"none",cursor:"pointer",color:t.cfg.colors.danger,fontSize:"13px"},onClick:()=>t.setSceneData(f=>{const p={...f};return delete p[s],delete p[s+"_name"],p})},"Remove")):m.createElement("button",{type:"button",onClick:()=>{var f;return(f=o.current)==null?void 0:f.click()},style:{...r,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",cursor:"pointer",color:t.cfg.colors.textMuted,fontSize:"14px"}},l?"Uploading…":"⬆ Upload a test case"),E("input",{key:"file-input",ref:o,type:"file",accept:n.accept||".pdf,.docx,.txt,.md,.csv,.json",style:{display:"none"},onChange:u}))}),z1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,options:o,label:l,fieldStyle:c}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const h=m.useRef(s);h.current=s;const a=m.useRef(c);a.current=c;const u=m.useCallback(p=>{h.current(p.target.value)},[]),f=m.createElement("select",{name:t,required:r,value:n??"",onChange:u,style:{...a.current,cursor:"pointer",appearance:"none"}},i?m.createElement("option",{key:"__placeholder",value:""},i):null,...o.map((p,g)=>m.createElement("option",{key:g,value:typeof p=="string"?p:p.value},typeof p=="string"?p:p.label)));return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},l),f):f}),F1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,rows:o,label:l,fieldStyle:c}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const h=m.useRef(s);h.current=s;const a=m.useRef(c);a.current=c;const u=m.useCallback(p=>{h.current(p.target.value)},[]),f=m.createElement("textarea",{name:t,placeholder:i,required:r,rows:o||4,value:n??"",onChange:u,style:{...a.current,resize:"vertical",fontFamily:"inherit"}});return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},l),f):f});function cm(e,t,n,s,i,r,o,l){var h,a;const c=[];if(o.forEach((u,f)=>{var x;const p=`${n}-field-${f}`,g=u.name||((x=u.label)==null?void 0:x.toLowerCase())||"",d={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:u.borderless?u.backgroundColor||"transparent":e.cfg.colors.surface,color:u.textColor||e.cfg.colors.text,colorScheme:e.cfg.colorMode==="light"?"light":"dark",border:u.borderless?"none":`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},w={width:"100%",marginBottom:"1rem"},C=k=>k.value?e.interpolateText(String(k.value)):"";if(u.type==="richtext")c.push(m.createElement(T1,{key:p,api:e,field:u,fieldName:g,value:e.sceneData[g]??C(u),onChange:k=>e.setSceneData(S=>({...S,[g]:k}))}));else if(u.type==="textarea"){const k=u.rows||4;c.push(m.createElement(F1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label,required:u.required,rows:k,label:u.label,fieldStyle:d}))}else if(u.type==="select")if(u.dataSource)c.push(m.createElement($1,{key:p,api:e,field:u,fieldName:g,fieldKey:p,fieldStyle:d,fieldWrapperStyle:w}));else{const k=Array.isArray(u.options)?u.options:[];c.push(m.createElement(z1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label||"Select...",required:u.required,options:k,label:u.label,fieldStyle:d}))}else if(u.type==="advanced-select")c.push(m.createElement("div",{key:`${p}-wrap`,style:w},m.createElement(lm,{key:p,api:e,c:{...u,name:g,options:u.options},componentKey:p})));else if(u.type==="file")c.push(m.createElement("div",{key:`${p}-wrap`,style:w},m.createElement(L1,{key:p,api:e,field:u,fieldName:g,label:u.label,fieldStyle:d})));else if(u.tags)c.push(m.createElement(B1,{key:p,api:e,field:u,value:e.sceneData[g]??C(u),onChange:k=>e.setSceneData(S=>({...S,[g]:k}))}));else{const k=u.type==="email"?"email":u.type==="password"?"password":u.type==="number"?"number":u.type==="date"?"date":"text";c.push(m.createElement(D1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label,required:u.required,inputType:k,label:u.label,fieldStyle:d,onKeyDown:u.onKeyDown?()=>e.handleButtonClick(u.onKeyDown):void 0}))}}),l){const u={padding:"0.75rem 1.5rem",borderRadius:e.cfg.components.inputRadius,cursor:"pointer",fontWeight:600,width:"100%",marginTop:"1rem"},f=l.className?((h=e.parseClassNameResponsive)==null?void 0:h.call(e,l.className,`${n}-submit`))??e.parseClassName(l.className):{},p=!!l.className&&/(^|\s)bg-[^\s]+/.test(l.className),g=!!l.className&&/(^|\s)text-[^\s]+/.test(l.className),d={...u,...f,...!p&&{backgroundColor:e.cfg.colors.primary},...!g&&{color:"#fff",border:"none"}},w=`${n}-submit`,C=!!((a=e.buttonLoading)!=null&&a[w]),x=()=>{var L,O,H,U,q;const P=[],I=e.sceneData||{};for(const X of o){const V=X.name||((L=X.label)==null?void 0:L.toLowerCase()),D=I[V],j=X.label||V;if(X.required&&(D==null||String(D).trim()==="")){P.push(`${j} is required`);continue}D==null||String(D).trim()===""||((O=X.validation)!=null&&O.pattern&&!new RegExp(X.validation.pattern).test(String(D))&&P.push(`${j} is invalid`),((H=X.validation)==null?void 0:H.min)!==void 0&&Number(D)<Number(X.validation.min)&&P.push(`${j} must be at least ${X.validation.min}`),((U=X.validation)==null?void 0:U.max)!==void 0&&Number(D)>Number(X.validation.max)&&P.push(`${j} must be at most ${X.validation.max}`),((q=X.validation)==null?void 0:q.minLength)!==void 0&&String(D).length<Number(X.validation.minLength)&&P.push(`${j} must be at least ${X.validation.minLength} characters`))}return P},k=()=>{var O,H;const P=x();if(P.length){(O=e.showToast)==null||O.call(e,P,"error");return}const I=()=>l.onClick?e.handleButtonClick(l.onClick,{onSuccess:l.onSuccess,onError:l.onError},{optimistic:l.optimistic,feedback:l.feedback}):Promise.resolve(),L=e.withLoading?e.withLoading(w,I):I();(H=L==null?void 0:L.catch)==null||H.call(L,()=>{})},S=l.onClick?()=>k():void 0,T=[];C?T.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{display:"inline-flex",width:"14px",height:"14px",marginRight:"6px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):l.icon&&T.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(l.icon,l.iconSize||16))),T.push(E("span",{key:"text"},l.text||"Submit")),c.push(E("button",{key:w,type:l.type||"submit",className:l.className,...e.getCommonProps(w,d,l),disabled:C||void 0,onClick:S},...T))}return E("form",{key:n,className:s,...r,onSubmit:u=>u.preventDefault()},...c)}const B1=m.memo(({api:e,field:t,value:n,onChange:s})=>{m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const i=m.useRef(null),r=(n||"").split(",").filter(Boolean).map(p=>p.trim()),[o,l]=m.useState(""),[c,h]=m.useState(!1),a=p=>{const g=p.target.value;if(g.includes(",")||g.includes(";")){const d=g.split(/[,;]+/).map(w=>w.trim()).filter(Boolean);if(d.length>0){const w=[...new Set([...r,...d])].join(", ");s(w)}l("")}else l(g)},u=p=>{if(p.key==="Enter"||p.key===","||p.key===";"){p.preventDefault();const g=o.trim();g&&(s([...new Set([...r,g])].join(", ")),l(""))}else p.key==="Backspace"&&!o&&r.length>0&&s(r.slice(0,-1).join(", "))},f=()=>{const p=o.trim();p&&(s([...new Set([...r,p])].join(", ")),l(""))};return E("div",{key:"tags",style:{width:"100%",marginBottom:"1rem"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,E("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",padding:"0.5rem 0.75rem",borderRadius:e.cfg.components.inputRadius||"8px",backgroundColor:e.cfg.colors.surface,border:`1px solid ${c?e.cfg.colors.primary:e.cfg.colors.border}`,cursor:"text",outline:"none",transition:"border-color 0.2s"},onClick:()=>{var p;return(p=i.current)==null?void 0:p.focus()}},...r.map((p,g)=>E("span",{key:g,style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",backgroundColor:e.cfg.colors.background,border:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.text,fontSize:"13px",lineHeight:"1.4"}},E("span",null,p),E("button",{type:"button",onMouseDown:d=>{d.preventDefault(),d.stopPropagation(),s(r.filter((w,C)=>C!==g).join(", "))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"0",fontSize:"14px",lineHeight:"1",display:"flex",alignItems:"center",fontFamily:"inherit"}},"×"))),E("input",{ref:i,type:"text",value:o,onChange:a,onKeyDown:u,onFocus:()=>h(!0),onBlur:()=>{h(!1),f()},placeholder:t.placeholder||(r.length>0?"":"Add email..."),style:{flex:1,minWidth:"100px",border:"none",outline:"none",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"14px",fontFamily:"inherit",padding:"2px 0"}})))});function W1(e,t,n){const s=e.interpolateText(t.text||t.content||"");if(!s)return null;const i=d=>{const w=[],C=/(\*\*(.+?)\*\*)|(\*(.+?)\*)|(`(.+?)`)|(\[(.+?)\]\((.+?)\))|(~~(.+?)~~)/g;let x=0,k;for(;(k=C.exec(d))!==null;)k.index>x&&w.push(d.slice(x,k.index)),k[2]?w.push(E("strong",{key:w.length},k[2])):k[4]?w.push(E("em",{key:w.length},k[4])):k[6]?w.push(E("code",{key:w.length},k[6])):k[8]?w.push(E("a",{key:w.length,href:k[9],target:"_blank",rel:"noopener noreferrer"},k[8])):k[11]&&w.push(E("del",{key:w.length},k[11])),x=k.index+k[0].length;return x<d.length&&w.push(d.slice(x)),w},r=s.split(`
|
|
15
|
+
*/const Ff={title:"",visible:!0,hitTestTolerance:3,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var Dh,Lh;function _n(e,t){const n=function(s,i){switch(s){case 0:default:return[];case 1:return[i,i];case 2:return[2*i,2*i];case 3:return[6*i,6*i];case 4:return[i,4*i]}}(t,e.lineWidth);return e.setLineDash(n),n}function Bf(e,t,n,s){e.beginPath();const i=e.lineWidth%2?.5:0;e.moveTo(n,t+i),e.lineTo(s,t+i),e.stroke()}function pe(e,t){if(!e)throw new Error("Assertion failed"+(t?": "+t:""))}function Re(e){if(e===void 0)throw new Error("Value is undefined");return e}function K(e){if(e===null)throw new Error("Value is null");return e}function Mn(e){return K(Re(e))}(function(e){e[e.Simple=0]="Simple",e[e.WithSteps=1]="WithSteps",e[e.Curved=2]="Curved"})(Dh||(Dh={})),function(e){e[e.Solid=0]="Solid",e[e.Dotted=1]="Dotted",e[e.Dashed=2]="Dashed",e[e.LargeDashed=3]="LargeDashed",e[e.SparseDotted=4]="SparseDotted"}(Lh||(Lh={}));class Zt{constructor(){this.t=[]}i(t,n,s){const i={h:t,l:n,o:s===!0};this.t.push(i)}_(t){const n=this.t.findIndex(s=>t===s.h);n>-1&&this.t.splice(n,1)}u(t){this.t=this.t.filter(n=>n.l!==t)}p(t,n,s){const i=[...this.t];this.t=this.t.filter(r=>!r.o),i.forEach(r=>r.h(t,n,s))}v(){return this.t.length>0}m(){this.t=[]}}function $e(e,...t){for(const n of t)for(const s in n)n[s]!==void 0&&Object.prototype.hasOwnProperty.call(n,s)&&!["__proto__","constructor","prototype"].includes(s)&&(typeof n[s]!="object"||e[s]===void 0||Array.isArray(n[s])?e[s]=n[s]:$e(e[s],n[s]));return e}function js(e){return typeof e=="number"&&isFinite(e)}function $i(e){return typeof e=="number"&&e%1==0}function Bi(e){return typeof e=="string"}function or(e){return typeof e=="boolean"}function an(e){const t=e;if(!t||typeof t!="object")return t;let n,s,i;for(s in n=Array.isArray(t)?[]:{},t)t.hasOwnProperty(s)&&(i=t[s],n[s]=i&&typeof i=="object"?an(i):i);return n}function zh(e){return e!==null}function Ni(e){return e===null?void 0:e}const Wf="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function Ir(e,t,n){return t===void 0&&(t=Wf),`${n=n!==void 0?`${n} `:""}${e}px ${t}`}class Cv{constructor(t){this.M={S:1,C:5,P:NaN,k:"",T:"",R:"",D:"",I:0,V:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,n=this.F(),s=this.W();return t.P===n&&t.T===s||(t.P=n,t.T=s,t.k=Ir(n,s),t.A=2.5/12*n,t.I=t.A,t.V=n/12*t.C,t.B=n/12*t.C,t.L=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function Po(e){return e<0?0:e>255?255:Math.round(e)||0}function Fh(e){return .199*e[0]+.687*e[1]+.114*e[2]}class kv{constructor(t,n){this.j=new Map,this.q=t,n&&(this.j=n)}Y(t,n){if(t==="transparent")return t;const s=this.K(t),i=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${n*i})`}G(t){const n=this.K(t);return{Z:`rgb(${n[0]}, ${n[1]}, ${n[2]})`,X:Fh(n)>160?"black":"white"}}J(t){return Fh(this.K(t))}tt(t,n,s){const[i,r,o,l]=this.K(t),[c,h,a,u]=this.K(n),f=[Po(i+s*(c-i)),Po(r+s*(h-r)),Po(o+s*(a-o)),(p=l+s*(u-l),p<=0||p>1?Math.min(Math.max(p,0),1):Math.round(1e4*p)/1e4)];var p;return`rgba(${f[0]}, ${f[1]}, ${f[2]}, ${f[3]})`}K(t){const n=this.j.get(t);if(n)return n;const s=function(o){const l=document.createElement("div");l.style.display="none",document.body.appendChild(l),l.style.color=o;const c=window.getComputedStyle(l).color;return document.body.removeChild(l),c}(t),i=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!i){if(this.q.length)for(const o of this.q){const l=o(t);if(l)return this.j.set(t,l),l}throw new Error(`Failed to parse color: ${t}`)}const r=[parseInt(i[1],10),parseInt(i[2],10),parseInt(i[3],10),i[4]?parseFloat(i[4]):1];return this.j.set(t,r),r}}class Mv{constructor(){this.it=[]}nt(t){this.it=t}st(t,n,s){this.it.forEach(i=>{i.st(t,n,s)})}}class Nn{st(t,n,s){t.useBitmapCoordinateSpace(i=>this.et(i,n,s))}}class Ev extends Nn{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:s}){if(this.rt===null||this.rt.lt===null)return;const i=this.rt.lt,r=this.rt,o=Math.max(1,Math.floor(n))%2/2,l=c=>{t.beginPath();for(let h=i.to-1;h>=i.from;--h){const a=r.ot[h],u=Math.round(a._t*n)+o,f=a.ut*s,p=c*s+o;t.moveTo(u,f),t.arc(u,f,p,0,2*Math.PI)}t.fill()};r.ct>0&&(t.fillStyle=r.dt,l(r.ft+r.ct)),t.fillStyle=r.vt,l(r.ft)}}function Tv(){return{ot:[{_t:0,ut:0,wt:0,Mt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const Av={from:0,to:1};class Rv{constructor(t,n,s){this.gt=new Mv,this.bt=[],this.St=[],this.xt=!0,this.O=t,this.Ct=n,this.yt=s,this.gt.nt(this.bt)}Pt(t){this.kt(),this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.gt}kt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.St=t.map(Tv),this.bt=this.St.map(n=>{const s=new Ev;return s.ht(n),s}),this.gt.nt(this.bt))}Rt(){const t=this.Ct.N().mode===2||!this.Ct.It(),n=this.yt.Vt(),s=this.Ct.Bt(),i=this.O.Et();this.kt(),n.forEach((r,o)=>{const l=this.St[o],c=r.At(s),h=r.Lt();!t&&c!==null&&r.It()&&h!==null?(l.vt=c.zt,l.ft=c.ft,l.ct=c.Ot,l.ot[0].Mt=c.Mt,l.ot[0].ut=r.Ft().Nt(c.Mt,h.Wt),l.dt=c.Ht??this.O.Ut(l.ot[0].ut/r.Ft().$t()),l.ot[0].wt=s,l.ot[0]._t=i.jt(s),l.lt=Av):l.lt=null})}}class Pv extends Nn{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null)return;const r=this.qt.Yt.It,o=this.qt.Kt.It;if(!r&&!o)return;const l=Math.round(this.qt._t*s),c=Math.round(this.qt.ut*i);t.lineCap="butt",r&&l>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*s),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,_n(t,this.qt.Yt.Gt),function(h,a,u,f){h.beginPath();const p=h.lineWidth%2?.5:0;h.moveTo(a+p,u),h.lineTo(a+p,f),h.stroke()}(t,l,0,n.height)),o&&c>=0&&(t.lineWidth=Math.floor(this.qt.Kt.ct*i),t.strokeStyle=this.qt.Kt.R,t.fillStyle=this.qt.Kt.R,_n(t,this.qt.Kt.Gt),Bf(t,c,0,n.width))}}class _v{constructor(t,n){this.xt=!0,this.Zt={Yt:{ct:1,Gt:0,R:"",It:!1},Kt:{ct:1,Gt:0,R:"",It:!1},_t:0,ut:0},this.Xt=new Pv(this.Zt),this.Jt=t,this.yt=n}Pt(){this.xt=!0}Tt(t){return this.xt&&(this.Rt(),this.xt=!1),this.Xt}Rt(){const t=this.Jt.It(),n=this.yt.Qt().N().crosshair,s=this.Zt;if(n.mode===2)return s.Kt.It=!1,void(s.Yt.It=!1);s.Kt.It=t&&this.Jt.ti(this.yt),s.Yt.It=t&&this.Jt.ii(),s.Kt.ct=n.horzLine.width,s.Kt.Gt=n.horzLine.style,s.Kt.R=n.horzLine.color,s.Yt.ct=n.vertLine.width,s.Yt.Gt=n.vertLine.style,s.Yt.R=n.vertLine.color,s._t=this.Jt.ni(),s.ut=this.Jt.si()}}function $v(e,t,n,s,i,r){e.fillRect(t+r,n,s-2*r,r),e.fillRect(t+r,n+i-r,s-2*r,r),e.fillRect(t,n,r,i),e.fillRect(t+s-r,n,r,i)}function Yr(e,t,n,s,i,r){e.save(),e.globalCompositeOperation="copy",e.fillStyle=r,e.fillRect(t,n,s,i),e.restore()}function Bh(e,t,n,s,i,r){e.beginPath(),e.roundRect?e.roundRect(t,n,s,i,r):(e.lineTo(t+s-r[1],n),r[1]!==0&&e.arcTo(t+s,n,t+s,n+r[1],r[1]),e.lineTo(t+s,n+i-r[2]),r[2]!==0&&e.arcTo(t+s,n+i,t+s-r[2],n+i,r[2]),e.lineTo(t+r[3],n+i),r[3]!==0&&e.arcTo(t,n+i,t,n+i-r[3],r[3]),e.lineTo(t,n+r[0]),r[0]!==0&&e.arcTo(t,n,t+r[0],n,r[0]))}function Wh(e,t,n,s,i,r,o=0,l=[0,0,0,0],c=""){if(e.save(),!o||!c||c===r)return Bh(e,t,n,s,i,l),e.fillStyle=r,e.fill(),void e.restore();const h=o/2;var a;Bh(e,t+h,n+h,s-o,i-o,(a=-h,l.map(u=>u===0?u:u+a))),r!=="transparent"&&(e.fillStyle=r,e.fill()),c!=="transparent"&&(e.lineWidth=o,e.strokeStyle=c,e.closePath(),e.stroke()),e.restore()}function jf(e,t,n,s,i,r,o){e.save(),e.globalCompositeOperation="copy";const l=e.createLinearGradient(0,0,0,i);l.addColorStop(0,r),l.addColorStop(1,o),e.fillStyle=l,e.fillRect(t,n,s,i),e.restore()}class jh{constructor(t,n){this.ht(t,n)}ht(t,n){this.qt=t,this.ei=n}$t(t,n){return this.qt.It?t.P+t.A+t.I:0}st(t,n,s,i){if(!this.qt.It||this.qt.ri.length===0)return;const r=this.qt.R,o=this.ei.Z,l=t.useBitmapCoordinateSpace(c=>{const h=c.context;h.font=n.k;const a=this.hi(c,n,s,i),u=a.ai;return a.li?Wh(h,u.oi,u._i,u.ui,u.ci,o,u.di,[u.ft,0,0,u.ft],o):Wh(h,u.fi,u._i,u.ui,u.ci,o,u.di,[0,u.ft,u.ft,0],o),this.qt.pi&&(h.fillStyle=r,h.fillRect(u.fi,u.mi,u.wi-u.fi,u.Mi)),this.qt.gi&&(h.fillStyle=n.D,h.fillRect(a.li?u.bi-u.di:0,u._i,u.di,u.Si-u._i)),a});t.useMediaCoordinateSpace(({context:c})=>{const h=l.xi;c.font=n.k,c.textAlign=l.li?"right":"left",c.textBaseline="middle",c.fillStyle=r,c.fillText(this.qt.ri,h.Ci,(h._i+h.Si)/2+h.yi)})}hi(t,n,s,i){const{context:r,bitmapSize:o,mediaSize:l,horizontalPixelRatio:c,verticalPixelRatio:h}=t,a=this.qt.pi||!this.qt.Pi?n.C:0,u=this.qt.ki?n.S:0,f=n.A+this.ei.Ti,p=n.I+this.ei.Ri,g=n.V,d=n.B,w=this.qt.ri,C=n.P,x=s.Di(r,w),k=Math.ceil(s.Ii(r,w)),S=C+f+p,T=n.S+g+d+k+a,P=Math.max(1,Math.floor(h));let I=Math.round(S*h);I%2!=P%2&&(I+=1);const L=u>0?Math.max(1,Math.floor(u*c)):0,O=Math.round(T*c),H=Math.round(a*c),U=this.ei.Vi??this.ei.Bi??this.ei.Ei,q=Math.round(U*h)-Math.floor(.5*h),X=Math.floor(q+P/2-I/2),j=X+I,D=i==="right",V=D?l.width-u:u,J=D?o.width-L:L;let nt,it,Q;return D?(nt=J-O,it=J-H,Q=V-a-g-u):(nt=J+O,it=J+H,Q=V+a+g),{li:D,ai:{_i:X,mi:q,Si:j,ui:O,ci:I,ft:2*c,di:L,oi:nt,fi:J,wi:it,Mi:P,bi:o.width},xi:{_i:X/h,Si:j/h,Ci:Q,yi:x}}}}class Xr{constructor(t){this.Ai={Ei:0,Z:"#000",Ri:0,Ti:0},this.Li={ri:"",It:!1,pi:!0,Pi:!1,Ht:"",R:"#FFF",gi:!1,ki:!1},this.zi={ri:"",It:!1,pi:!1,Pi:!0,Ht:"",R:"#FFF",gi:!0,ki:!0},this.xt=!0,this.Oi=new(t||jh)(this.Li,this.Ai),this.Ni=new(t||jh)(this.zi,this.Ai)}ri(){return this.Fi(),this.Li.ri}Ei(){return this.Fi(),this.Ai.Ei}Pt(){this.xt=!0}$t(t,n=!1){return Math.max(this.Oi.$t(t,n),this.Ni.$t(t,n))}Wi(){return this.Ai.Vi??null}Hi(){return this.Ai.Vi??this.Ai.Bi??this.Ei()}Ui(t){this.Ai.Bi=t??void 0}$i(){return this.Fi(),this.Li.It||this.zi.It}ji(){return this.Fi(),this.Li.It}Tt(t){return this.Fi(),this.Li.pi=this.Li.pi&&t.N().ticksVisible,this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Ni}Fi(){this.xt&&(this.Li.pi=!0,this.zi.pi=!1,this.Yi(this.Li,this.zi,this.Ai))}}class Nv extends Xr{constructor(t,n,s){super(),this.Jt=t,this.Ki=n,this.Gi=s}Yi(t,n,s){if(t.It=!1,this.Jt.N().mode===2)return;const i=this.Jt.N().horzLine;if(!i.labelVisible)return;const r=this.Ki.Lt();if(!this.Jt.It()||this.Ki.Zi()||r===null)return;const o=this.Ki.Xi().G(i.labelBackgroundColor);s.Z=o.Z,t.R=o.X;const l=2/12*this.Ki.P();s.Ti=l,s.Ri=l;const c=this.Gi(this.Ki);s.Ei=c.Ei,t.ri=this.Ki.Ji(c.Mt,r),t.It=!0}}const Iv=/[1-9]/g;class Vf{constructor(){this.qt=null}ht(t){this.qt=t}st(t,n){if(this.qt===null||this.qt.It===!1||this.qt.ri.length===0)return;const s=t.useMediaCoordinateSpace(({context:f})=>(f.font=n.k,Math.round(n.Qi.Ii(f,K(this.qt).ri,Iv))));if(s<=0)return;const i=n.tn,r=s+2*i,o=r/2,l=this.qt.nn;let c=this.qt.Ei,h=Math.floor(c-o)+.5;h<0?(c+=Math.abs(0-h),h=Math.floor(c-o)+.5):h+r>l&&(c-=Math.abs(l-(h+r)),h=Math.floor(c-o)+.5);const a=h+r,u=Math.ceil(0+n.S+n.C+n.A+n.P+n.I);t.useBitmapCoordinateSpace(({context:f,horizontalPixelRatio:p,verticalPixelRatio:g})=>{const d=K(this.qt);f.fillStyle=d.Z;const w=Math.round(h*p),C=Math.round(0*g),x=Math.round(a*p),k=Math.round(u*g),S=Math.round(2*p);if(f.beginPath(),f.moveTo(w,C),f.lineTo(w,k-S),f.arcTo(w,k,w+S,k,S),f.lineTo(x-S,k),f.arcTo(x,k,x,k-S,S),f.lineTo(x,C),f.fill(),d.pi){const T=Math.round(d.Ei*p),P=C,I=Math.round((P+n.C)*g);f.fillStyle=d.R;const L=Math.max(1,Math.floor(p)),O=Math.floor(.5*p);f.fillRect(T-O,P,L,I-P)}}),t.useMediaCoordinateSpace(({context:f})=>{const p=K(this.qt),g=0+n.S+n.C+n.A+n.P/2;f.font=n.k,f.textAlign="left",f.textBaseline="middle",f.fillStyle=p.R;const d=n.Qi.Di(f,"Apr0");f.translate(h+i,g+d),f.fillText(p.ri,0,0)})}}class Dv{constructor(t,n,s){this.xt=!0,this.Xt=new Vf,this.Zt={It:!1,Z:"#4c525e",R:"white",ri:"",nn:0,Ei:NaN,pi:!0},this.Ct=t,this.sn=n,this.Gi=s}Pt(){this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Xt.ht(this.Zt),this.Xt}Rt(){const t=this.Zt;if(t.It=!1,this.Ct.N().mode===2)return;const n=this.Ct.N().vertLine;if(!n.labelVisible)return;const s=this.sn.Et();if(s.Zi())return;t.nn=s.nn();const i=this.Gi();if(i===null)return;t.Ei=i.Ei;const r=s.en(this.Ct.Bt());t.ri=s.rn(K(r)),t.It=!0;const o=this.sn.Xi().G(n.labelBackgroundColor);t.Z=o.Z,t.R=o.X,t.pi=s.N().ticksVisible}}class Of{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(t){this.an=t}Ft(){return this.hn}un(t){this.hn=t}cn(t){return[]}dn(){return[]}It(){return!0}}var Vh;(function(e){e[e.Normal=0]="Normal",e[e.Magnet=1]="Magnet",e[e.Hidden=2]="Hidden",e[e.MagnetOHLC=3]="MagnetOHLC"})(Vh||(Vh={}));class Lv extends Of{constructor(t,n){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.Mn=new WeakMap,this.gn=new WeakMap,this.bn=NaN,this.Sn=NaN,this.xn=NaN,this.Cn=NaN,this.sn=t,this.yn=n,this.Pn=((i,r)=>o=>{const l=r(),c=i();if(o===K(this.yt).kn())return{Mt:c,Ei:l};{const h=K(o.Lt());return{Mt:o.Tn(l,h),Ei:l}}})(()=>this.fn,()=>this.Sn);const s=((i,r)=>()=>{const o=this.sn.Et().Rn(i()),l=r();return o&&Number.isFinite(l)?{wt:o,Ei:l}:null})(()=>this.pn,()=>this.ni());this.Dn=new Dv(this,t,s)}N(){return this.yn}In(t,n){this.xn=t,this.Cn=n}Vn(){this.xn=NaN,this.Cn=NaN}Bn(){return this.xn}En(){return this.Cn}An(t,n,s){this.wn||(this.wn=!0),this.vn=!0,this.Ln(t,n,s)}Bt(){return this.pn}ni(){return this.bn}si(){return this.Sn}It(){return this.vn}zn(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.Sn=NaN,this.yt=null,this.Vn(),this.Nn()}Fn(t){if(!this.yn.doNotSnapToHiddenSeriesIndices)return t;const n=this.sn,s=n.Et();let i=null,r=null;for(const h of n.Wn()){const a=h.Un().Hn(t,-1);if(a){if(a.$n===t)return t;(i===null||a.$n>i)&&(i=a.$n)}const u=h.Un().Hn(t,1);if(u){if(u.$n===t)return t;(r===null||u.$n<r)&&(r=u.$n)}}const o=[i,r].filter(zh);if(o.length===0)return t;const l=s.jt(t),c=o.map(h=>Math.abs(l-s.jt(h)));return o[c.indexOf(Math.min(...c))]}jn(t){let n=this.Mn.get(t);n||(n=new _v(this,t),this.Mn.set(t,n));let s=this.gn.get(t);return s||(s=new Rv(this.sn,this,t),this.gn.set(t,s)),[n,s]}ti(t){return t===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(t,n){this.vn&&this.yt===t||this.mn.clear();const s=[];return this.yt===t&&s.push(this.Yn(this.mn,n,this.Pn)),s}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Gn().forEach(t=>{var n,s;(n=this.Mn.get(t))==null||n.Pt(),(s=this.gn.get(t))==null||s.Pt()}),this.mn.forEach(t=>t.Pt()),this.Dn.Pt()}Zn(t){return t&&!t.kn().Zi()?t.kn():null}Ln(t,n,s){this.Xn(t,n,s)&&this.Nn()}Xn(t,n,s){const i=this.bn,r=this.Sn,o=this.fn,l=this.pn,c=this.yt,h=this.Zn(s);this.pn=t,this.bn=isNaN(t)?NaN:this.sn.Et().jt(t),this.yt=s;const a=h!==null?h.Lt():null;return h!==null&&a!==null?(this.fn=n,this.Sn=h.Nt(n,a)):(this.fn=NaN,this.Sn=NaN),i!==this.bn||r!==this.Sn||l!==this.pn||o!==this.fn||c!==this.yt}On(){const t=this.sn.Jn().map(s=>s.Un().Qn()).filter(zh),n=t.length===0?null:Math.max(...t);this.pn=n!==null?n:NaN}Yn(t,n,s){let i=t.get(n);return i===void 0&&(i=new Nv(this,n,s),t.set(n,i)),i}}function Qr(e){return e==="left"||e==="right"}class fe{constructor(t){this.ts=new Map,this.ns=[],this.ss=t}es(t,n){const s=function(i,r){return i===void 0?r:{rs:Math.max(i.rs,r.rs),hs:i.hs||r.hs}}(this.ts.get(t),n);this.ts.set(t,s)}ls(){return this.ss}_s(t){const n=this.ts.get(t);return n===void 0?{rs:this.ss}:{rs:Math.max(this.ss,n.rs),hs:n.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(t){this.cs(),this.ns=[{ds:1,Wt:t}]}ps(t){this.vs(),this.ns.push({ds:5,Wt:t})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}Ms(t){this.cs(),this.ns.push({ds:2,Wt:t})}gs(t){this.cs(),this.ns.push({ds:3,Wt:t})}bs(){return this.ns}Ss(t){for(const n of t.ns)this.xs(n);this.ss=Math.max(this.ss,t.ss),t.ts.forEach((n,s)=>{this.es(s,n)})}static Cs(){return new fe(2)}static ys(){return new fe(3)}xs(t){switch(t.ds){case 0:this.us();break;case 1:this.fs(t.Wt);break;case 2:this.Ms(t.Wt);break;case 3:this.gs(t.Wt);break;case 4:this.ws();break;case 5:this.ps(t.Wt);break;case 6:this.vs()}}vs(){const t=this.ns.findIndex(n=>n.ds===5);t!==-1&&this.ns.splice(t,1)}}class Uf{formatTickmarks(t){return t.map(n=>this.format(n))}}const Oh=".";function ln(e,t){if(!js(e))return"n/a";if(!$i(t))throw new TypeError("invalid length");if(t<0||t>16)throw new TypeError("invalid length");return t===0?e.toString():("0000000000000000"+e.toString()).slice(-t)}class Jr extends Uf{constructor(t,n){if(super(),n||(n=1),js(t)&&$i(t)||(t=100),t<0)throw new TypeError("invalid base");this.Ki=t,this.Ps=n,this.ks()}format(t){const n=t<0?"−":"";return t=Math.abs(t),n+this.Ts(t)}ks(){if(this.Rs=0,this.Ki>0&&this.Ps>0){let t=this.Ki;for(;t>1;)t/=10,this.Rs++}}Ts(t){const n=this.Ki/this.Ps;let s=Math.floor(t),i="";const r=this.Rs!==void 0?this.Rs:NaN;if(n>1){let o=+(Math.round(t*n)-s*n).toFixed(this.Rs);o>=n&&(o-=n,s+=1),i=Oh+ln(+o.toFixed(this.Rs)*this.Ps,r)}else s=Math.round(s*n)/n,r>0&&(i=Oh+ln(0,r));return s.toFixed(0)+i}}class Hf extends Jr{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class zv extends Uf{constructor(t){super(),this.Ds=t}format(t){let n="";return t<0&&(n="-",t=-t),t<995?n+this.Is(t):t<999995?n+this.Is(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),n+this.Is(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),n+this.Is(t/1e9)+"B")}Is(t){let n;const s=Math.pow(10,this.Ds);return n=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Ds).replace(/\.?0+$/,""):String(t),n.replace(/(\.[1-9]*)0+$/,(i,r)=>r)}}const Fv=/[2-9]/g;class Dr{constructor(t=50){this.Vs=0,this.Bs=1,this.Es=1,this.As={},this.Ls=new Map,this.zs=t}Os(){this.Vs=0,this.Ls.clear(),this.Bs=1,this.Es=1,this.As={}}Ii(t,n,s){return this.Ns(t,n,s).width}Di(t,n,s){const i=this.Ns(t,n,s);return((i.actualBoundingBoxAscent||0)-(i.actualBoundingBoxDescent||0))/2}Ns(t,n,s){const i=s||Fv,r=String(n).replace(i,"0");if(this.Ls.has(r))return Re(this.Ls.get(r)).Fs;if(this.Vs===this.zs){const l=this.As[this.Es];delete this.As[this.Es],this.Ls.delete(l),this.Es++,this.Vs--}t.save(),t.textBaseline="middle";const o=t.measureText(r);return t.restore(),o.width===0&&n.length||(this.Ls.set(r,{Fs:o,Ws:this.Bs}),this.As[this.Bs]=r,this.Vs++,this.Bs++),o}}class Bv{constructor(t){this.Hs=null,this.M=null,this.Us="right",this.$s=t}js(t,n,s){this.Hs=t,this.M=n,this.Us=s}st(t){this.M!==null&&this.Hs!==null&&this.Hs.st(t,this.M,this.$s,this.Us)}}class qf{constructor(t,n,s){this.qs=t,this.$s=new Dr(50),this.Ys=n,this.O=s,this.F=-1,this.Xt=new Bv(this.$s)}Tt(){const t=this.O.Ks(this.Ys);if(t===null)return null;const n=t.Gs(this.Ys)?t.Zs():this.Ys.Ft();if(n===null)return null;const s=t.Xs(n);if(s==="overlay")return null;const i=this.O.Js();return i.P!==this.F&&(this.F=i.P,this.$s.Os()),this.Xt.js(this.qs.qi(),i,s),this.Xt}}class Wv extends Nn{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Qs(t,n){var o;if(!((o=this.qt)!=null&&o.It))return null;const{ut:s,ct:i,te:r}=this.qt;return n>=s-i-7&&n<=s+i+7?{ie:this.qt,ne:Math.abs(n-s),se:2,ee:"price-line",te:r}:null}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null||this.qt.It===!1)return;const r=Math.round(this.qt.ut*i);r<0||r>n.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*s),_n(t,this.qt.Gt),Bf(t,r,0,n.width))}}class vl{constructor(t){this.re={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Gt:0,It:!1},this.he=new Wv,this.xt=!0,this.ae=t,this.le=t.Qt(),this.he.ht(this.re)}Pt(){this.xt=!0}Tt(){return this.ae.It()?(this.xt&&(this.oe(),this.xt=!1),this.he):null}}class jv extends vl{constructor(t){super(t)}oe(){this.re.It=!1;const t=this.ae.Ft(),n=t._e()._e;if(n!==2&&n!==3)return;const s=this.ae.N();if(!s.baseLineVisible||!this.ae.It())return;const i=this.ae.Lt();i!==null&&(this.re.It=!0,this.re.ut=t.Nt(i.Wt,i.Wt),this.re.R=s.baseLineColor,this.re.ct=s.baseLineWidth,this.re.Gt=s.baseLineStyle)}}class Vv extends Nn{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}ue(){return this.qt}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:s}){const i=this.qt;if(i===null)return;const r=Math.max(1,Math.floor(n)),o=r%2/2,l=Math.round(i.ce.x*n)+o,c=i.ce.y*s;t.fillStyle=i.de,t.beginPath();const h=Math.max(2,1.5*i.fe)*n;t.arc(l,c,h,0,2*Math.PI,!1),t.fill(),t.fillStyle=i.pe,t.beginPath(),t.arc(l,c,i.ft*n,0,2*Math.PI,!1),t.fill(),t.lineWidth=r,t.strokeStyle=i.ve,t.beginPath(),t.arc(l,c,i.ft*n+r/2,0,2*Math.PI,!1),t.stroke()}}const Ov=[{me:0,we:.25,Me:4,ge:10,be:.25,Se:0,xe:.4,Ce:.8},{me:.25,we:.525,Me:10,ge:14,be:0,Se:0,xe:.8,Ce:0},{me:.525,we:1,Me:14,ge:14,be:0,Se:0,xe:0,Ce:0}];class Uv{constructor(t){this.Xt=new Vv,this.xt=!0,this.ye=!0,this.Pe=performance.now(),this.ke=this.Pe-1,this.Te=t}Re(){this.ke=this.Pe-1,this.Pt()}De(){if(this.Pt(),this.Te.N().lastPriceAnimation===2){const t=performance.now(),n=this.ke-t;if(n>0)return void(n<650&&(this.ke+=2600));this.Pe=t,this.ke=t+2600}}Pt(){this.xt=!0}Ie(){this.ye=!0}It(){return this.Te.N().lastPriceAnimation!==0}Ve(){switch(this.Te.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.ke}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ye=!1):this.ye&&(this.Be(),this.ye=!1),this.Xt}Rt(){this.Xt.ht(null);const t=this.Te.Qt().Et(),n=t.Ee(),s=this.Te.Lt();if(n===null||s===null)return;const i=this.Te.Ae(!0);if(i.Le||!n.ze(i.$n))return;const r={x:t.jt(i.$n),y:this.Te.Ft().Nt(i.Mt,s.Wt)},o=i.R,l=this.Te.N().lineWidth,c=this.Oe(this.Ne(),o);this.Xt.ht({de:o,fe:l,pe:c.pe,ve:c.ve,ft:c.ft,ce:r})}Be(){const t=this.Xt.ue();if(t!==null){const n=this.Oe(this.Ne(),t.de);t.pe=n.pe,t.ve=n.ve,t.ft=n.ft}}Ne(){return this.Ve()?performance.now()-this.Pe:2599}Fe(t,n,s,i){const r=s+(i-s)*n;return this.Te.Qt().Xi().Y(t,r)}Oe(t,n){const s=t%2600/2600;let i;for(const h of Ov)if(s>=h.me&&s<=h.we){i=h;break}pe(i!==void 0,"Last price animation internal logic error");const r=(s-i.me)/(i.we-i.me);return{pe:this.Fe(n,r,i.be,i.Se),ve:this.Fe(n,r,i.xe,i.Ce),ft:(o=r,l=i.Me,c=i.ge,l+(c-l)*o)};var o,l,c}}class Hv extends vl{constructor(t){super(t)}oe(){const t=this.re;t.It=!1;const n=this.ae.N();if(!n.priceLineVisible||!this.ae.It())return;const s=this.ae.Ae(n.priceLineSource===0);s.Le||(t.It=!0,t.ut=s.Ei,t.R=this.ae.We(s.R),t.ct=n.priceLineWidth,t.Gt=n.priceLineStyle)}}class qv extends Xr{constructor(t){super(),this.Jt=t}Yi(t,n,s){t.It=!1,n.It=!1;const i=this.Jt;if(!i.It())return;const r=i.N(),o=r.lastValueVisible,l=i.He()!=="",c=r.seriesLastValueMode===0,h=i.Ae(!1);if(h.Le)return;o&&(t.ri=this.Ue(h,o,c),t.It=t.ri.length!==0),(l||c)&&(n.ri=this.$e(h,o,l,c),n.It=n.ri.length>0);const a=i.We(h.R),u=this.Jt.Qt().Xi().G(a);s.Z=u.Z,s.Ei=h.Ei,n.Ht=i.Qt().Ut(h.Ei/i.Ft().$t()),t.Ht=a,t.R=u.X,n.R=u.X}$e(t,n,s,i){let r="";const o=this.Jt.He();return s&&o.length!==0&&(r+=`${o} `),n&&i&&(r+=this.Jt.Ft().je()?t.qe:t.Ye),r.trim()}Ue(t,n,s){return n?s?this.Jt.Ft().je()?t.Ye:t.qe:t.ri:""}}function Uh(e,t,n,s){const i=Number.isFinite(t),r=Number.isFinite(n);return i&&r?e(t,n):i||r?i?t:n:s}class ke{constructor(t,n){this.Ke=t,this.Ge=n}Ze(t){return t!==null&&this.Ke===t.Ke&&this.Ge===t.Ge}Xe(){return new ke(this.Ke,this.Ge)}Je(){return this.Ke}Qe(){return this.Ge}tr(){return this.Ge-this.Ke}Zi(){return this.Ge===this.Ke||Number.isNaN(this.Ge)||Number.isNaN(this.Ke)}Ss(t){return t===null?this:new ke(Uh(Math.min,this.Je(),t.Je(),-1/0),Uh(Math.max,this.Qe(),t.Qe(),1/0))}ir(t){if(!js(t)||this.Ge-this.Ke===0)return;const n=.5*(this.Ge+this.Ke);let s=this.Ge-n,i=this.Ke-n;s*=t,i*=t,this.Ge=n+s,this.Ke=n+i}nr(t){js(t)&&(this.Ge+=t,this.Ke+=t)}sr(){return{minValue:this.Ke,maxValue:this.Ge}}static er(t){return t===null?null:new ke(t.minValue,t.maxValue)}}class Lr{constructor(t,n){this.rr=t,this.hr=n||null}ar(){return this.rr}lr(){return this.hr}sr(){return{priceRange:this.rr===null?null:this.rr.sr(),margins:this.hr||void 0}}static er(t){return t===null?null:new Lr(ke.er(t.priceRange),t.margins)}}const Gv=[2,4,8,16,32,64,128,256,512],Yv="Custom series with conflation reducer must have a priceValueBuilder method";class Xv extends vl{constructor(t,n){super(t),this._r=n}oe(){const t=this.re;t.It=!1;const n=this._r.N();if(!this.ae.It()||!n.lineVisible)return;const s=this._r.ur();s!==null&&(t.It=!0,t.ut=s,t.R=n.color,t.ct=n.lineWidth,t.Gt=n.lineStyle,t.te=this._r.N().id)}}class Qv extends Xr{constructor(t,n){super(),this.Te=t,this._r=n}Yi(t,n,s){t.It=!1,n.It=!1;const i=this._r.N(),r=i.axisLabelVisible,o=i.title!=="",l=this.Te;if(!r||!l.It())return;const c=this._r.ur();if(c===null)return;o&&(n.ri=i.title,n.It=!0),n.Ht=l.Qt().Ut(c/l.Ft().$t()),t.ri=this.cr(i.price),t.It=!0;const h=this.Te.Qt().Xi().G(i.axisLabelColor||i.color);s.Z=h.Z;const a=i.axisLabelTextColor||h.X;t.R=a,n.R=a,s.Ei=c}cr(t){const n=this.Te.Lt();return n===null?"":this.Te.Ft().Ji(t,n.Wt)}}class Jv{constructor(t,n){this.Te=t,this.yn=n,this.dr=new Xv(t,this),this.qs=new Qv(t,this),this.pr=new qf(this.qs,t,t.Qt())}vr(t){$e(this.yn,t),this.Pt(),this.Te.Qt().mr()}N(){return this.yn}wr(){return this.dr}Mr(){return this.pr}gr(){return this.qs}Pt(){this.dr.Pt(),this.qs.Pt()}ur(){const t=this.Te,n=t.Ft();if(t.Qt().Et().Zi()||n.Zi())return null;const s=t.Lt();return s===null?null:n.Nt(this.yn.price,s.Wt)}}class Kv{constructor(){this.br=new WeakMap}Sr(t,n,s){const i=1/n*s;if(t>=i)return 1;const r=i/t,o=Math.pow(2,Math.floor(Math.log2(r)));return Math.min(o,512)}Cr(t,n,s,i=!1,r){if(t.length===0||n<=1)return t;const o=this.yr(n);if(o<=1)return t;const l=this.Pr(t);let c=l.kr.get(o);return c!==void 0||(c=this.Tr(t,o,s,i,r,l.kr),l.kr.set(o,c)),c}Rr(t,n,s,i,r=!1,o){if(s<1||t.length===0)return t;const l=this.Pr(t),c=l.kr.get(s);if(!c)return this.Cr(t,s,i,r,o);const h=this.Dr(t,n,s,c,r,i,o);return l.kr.set(s,h),h}yr(t){if(t<=2)return 2;for(const n of Gv)if(t<=n)return n;return 512}Ir(t){if(t.length===0)return 0;const n=t[0],s=t[t.length-1];return 31*t.length+17*n.$n+13*s.$n}Tr(t,n,s,i=!1,r,o=new Map){if(n===2)return this.Vr(t,2,s,i,r);const l=n/2;let c=o.get(l);return c||(c=this.Tr(t,l,s,i,r,o),o.set(l,c)),this.Br(c,s,i,r)}Vr(t,n,s,i=!1,r){const o=this.Er(t,n,s,i,r);return this.Ar(o,i)}Br(t,n,s=!1,i){const r=this.Er(t,2,n,s,i);return this.Ar(r,s)}Er(t,n,s,i=!1,r){const o=[];for(let l=0;l<t.length;l+=n)if(t.length-l>=n){const c=this.Lr(t[l],t[l+1],s,i,r);c.zr=!1,o.push(c)}else if(o.length===0)o.push(this.Or(t[l],!0));else{const c=o[o.length-1];o[o.length-1]=this.Nr(c,t[l],s,i,r)}return o}Fr(t,n){return(t??1)+(n??1)}Lr(t,n,s,i=!1,r){if(!i||!s||!r){const h=t.Wt[1]>n.Wt[1]?t.Wt[1]:n.Wt[1],a=t.Wt[2]<n.Wt[2]?t.Wt[2]:n.Wt[2];return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:h,Yr:a,Kr:n.Wt[3],Gr:this.Fr(t.Gr,n.Gr),Zr:void 0,zr:!1}}const o=s(this.Xr(t,r),this.Xr(n,r)),l=r(o),c=l.length?l[l.length-1]:0;return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:Math.max(t.Wt[1],c),Yr:Math.min(t.Wt[2],c),Kr:c,Gr:this.Fr(t.Gr,n.Gr),Zr:o,zr:!1}}Nr(t,n,s,i=!1,r){if(!i||!s||!r)return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:t.qr>n.Wt[1]?t.qr:n.Wt[1],Yr:t.Yr<n.Wt[2]?t.Yr:n.Wt[2],Kr:n.Wt[3],Gr:t.Gr+(n.Gr??1),Zr:t.Zr,zr:!1};const o=t.Zr,l=this.Xr(n,r),c=o?{data:o,index:t.Wr,originalTime:t.Ur,time:t.Ur,priceValues:r(o)}:null,h=c?s(c,l):l.data,a=c?r(h):l.priceValues,u=a.length?a[a.length-1]:0;return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:Math.max(t.qr,u),Yr:Math.min(t.Yr,u),Kr:u,Gr:t.Gr+(n.Gr??1),Zr:h,zr:!1}}Jr(t,n,s,i,r,o,l=!1,c){const h=n===i?r:t[n];if(s-n==1)return this.Or(h,!0);const a=n+1===i?r:t[n+1];let u=this.Lr(h,a,o,l,c);for(let f=n+2;f<s;f++){const p=f===i?r:t[f];u=this.Nr(u,p,o,l,c)}return u}Xr(t,n){const s=t.ue??{};return{data:t.ue,index:t.$n,originalTime:t.Qr,time:t.wt,priceValues:n(s)}}th(t,n=!1){const s=n===!0,i=!!t.Zr;return{$n:t.Wr,wt:t.Ur,Qr:t.Ur,Wt:[s?t.Kr:t.jr,t.qr,t.Yr,t.Kr],Gr:t.Gr,ue:s?i?t.Zr:{wt:t.Ur}:void 0}}Ar(t,n=!1){return t.map(s=>this.th(s,n))}Dr(t,n,s,i,r=!1,o,l){if(i.length===0)return i;const c=t.length-1,h=Math.floor(c/s)*s;if(Math.min(h+s,t.length)-h<s&&t.length>s){const a=t.slice();return a[a.length-1]=n,this.Cr(a,s,o,r,l)}if(Math.floor((c-1)/s)===Math.floor(c/s)||i.length===1){const a=Math.min(h+s,t.length),u=a-h;if(u<=0)return i;const f=u===1?this.Or(h===c?n:t[h],!0):this.Jr(t,h,a,c,n,o,r,l);return i[i.length-1]=this.th(f,r),i}{const a=t.slice();return a[a.length-1]=n,this.Cr(a,s,o,r,l)}}Or(t,n=!1){return{Wr:t.$n,Hr:t.$n,Ur:t.wt,$r:t.wt,jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3],Gr:t.Gr??1,Zr:t.ue,zr:n}}Pr(t){const n=this.ih(t),s=this.Ir(t);return n.nh!==s&&(n.kr.clear(),n.nh=s),n}ih(t){let n=this.br.get(t);return n===void 0&&(n={nh:this.Ir(t),kr:new Map},this.br.set(t,n)),n}}class Zv extends Of{constructor(t){super(),this.sn=t}Qt(){return this.sn}}const tx={Bar:(e,t,n,s)=>{const i=t.upColor,r=t.downColor,o=K(e(n,s)),l=Mn(o.Wt[0])<=Mn(o.Wt[3]);return{sh:o.R??(l?i:r)}},Candlestick:(e,t,n,s)=>{const i=t.upColor,r=t.downColor,o=t.borderUpColor,l=t.borderDownColor,c=t.wickUpColor,h=t.wickDownColor,a=K(e(n,s)),u=Mn(a.Wt[0])<=Mn(a.Wt[3]);return{sh:a.R??(u?i:r),eh:a.Ht??(u?o:l),rh:a.hh??(u?c:h)}},Custom:(e,t,n,s)=>({sh:K(e(n,s)).R??t.color}),Area:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.vt??t.lineColor,vt:i.vt??t.lineColor,ah:i.ah??t.topColor,oh:i.oh??t.bottomColor}},Baseline:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.Wt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,_h:i._h??t.topLineColor,uh:i.uh??t.bottomLineColor,dh:i.dh??t.topFillColor1,fh:i.fh??t.topFillColor2,ph:i.ph??t.bottomFillColor1,mh:i.mh??t.bottomFillColor2}},Line:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.R??t.color,vt:i.R??t.color}},Histogram:(e,t,n,s)=>({sh:K(e(n,s)).R??t.color})};class ex{constructor(t){this.wh=(n,s)=>s!==void 0?s.Wt:this.Te.Un().Mh(n),this.Te=t,this.gh=tx[t.bh()]}Sh(t,n){return this.gh(this.wh,this.Te.N(),t,n)}}function Gf(e,t,n,s,i=0,r=t.length){let o=r-i;for(;0<o;){const l=o>>1,c=i+l;s(t[c],n)===e?(i=c+1,o-=l+1):o=l}return i}const es=Gf.bind(null,!0),xl=Gf.bind(null,!1);var Hh;(function(e){e[e.NearestLeft=-1]="NearestLeft",e[e.None=0]="None",e[e.NearestRight=1]="NearestRight"})(Hh||(Hh={}));const Sn=30;class nx{constructor(){this.xh=[],this.Ch=new Map,this.yh=new Map,this.Ph=[]}kh(){return this.Th()>0?this.xh[this.xh.length-1]:null}Rh(){return this.Th()>0?this.Dh(0):null}Qn(){return this.Th()>0?this.Dh(this.xh.length-1):null}Th(){return this.xh.length}Zi(){return this.Th()===0}ze(t){return this.Ih(t,0)!==null}Mh(t){return this.Hn(t)}Hn(t,n=0){const s=this.Ih(t,n);return s===null?null:{...this.Vh(s),$n:this.Dh(s)}}Bh(){return this.xh}Eh(t,n,s){if(this.Zi())return null;let i=null;for(const r of s)i=ar(i,this.Ah(t,n,r));return i}ht(t){this.yh.clear(),this.Ch.clear(),this.xh=t,this.Ph=t.map(n=>n.$n)}Lh(){return this.Ph}Dh(t){return this.xh[t].$n}Vh(t){return this.xh[t]}Ih(t,n){const s=this.zh(t);if(s===null&&n!==0)switch(n){case-1:return this.Oh(t);case 1:return this.Nh(t);default:throw new TypeError("Unknown search mode")}return s}Oh(t){let n=this.Fh(t);return n>0&&(n-=1),n!==this.xh.length&&this.Dh(n)<t?n:null}Nh(t){const n=this.Wh(t);return n!==this.xh.length&&t<this.Dh(n)?n:null}zh(t){const n=this.Fh(t);return n===this.xh.length||t<this.xh[n].$n?null:n}Fh(t){return es(this.xh,t,(n,s)=>n.$n<s)}Wh(t){return xl(this.xh,t,(n,s)=>n.$n>s)}Hh(t,n,s){let i=null;for(let r=t;r<n;r++){const o=this.xh[r].Wt[s];Number.isNaN(o)||(i===null?i={Uh:o,$h:o}:(o<i.Uh&&(i.Uh=o),o>i.$h&&(i.$h=o)))}return i}Ah(t,n,s){if(this.Zi())return null;let i=null;const r=K(this.Rh()),o=K(this.Qn()),l=Math.max(t,r),c=Math.min(n,o),h=Math.ceil(l/Sn)*Sn,a=Math.max(h,Math.floor(c/Sn)*Sn);{const f=this.Fh(l),p=this.Wh(Math.min(c,h,n));i=ar(i,this.Hh(f,p,s))}let u=this.Ch.get(s);u===void 0&&(u=new Map,this.Ch.set(s,u));for(let f=Math.max(h+1,l);f<a;f+=Sn){const p=Math.floor(f/Sn);let g=u.get(p);if(g===void 0){const d=this.Fh(p*Sn),w=this.Wh((p+1)*Sn-1);g=this.Hh(d,w,s),u.set(p,g)}i=ar(i,g)}{const f=this.Fh(a),p=this.Wh(c);i=ar(i,this.Hh(f,p,s))}return i}}function ar(e,t){return e===null?t:t===null?e:{Uh:Math.min(e.Uh,t.Uh),$h:Math.max(e.$h,t.$h)}}function _o(){return new nx}const zr={setLineStyle:_n};class sx{constructor(t){this.jh=t}st(t,n,s){this.jh.draw(t,zr)}qh(t,n,s){var i,r;(r=(i=this.jh).drawBackground)==null||r.call(i,t,zr)}}class ix{constructor(t){this.Ls=null,this.Yh=t}Tt(){var s;const t=this.Yh.renderer();if(t===null)return null;if(((s=this.Ls)==null?void 0:s.Kh)===t)return this.Ls.Gh;const n=new sx(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}class Yf{constructor(t){this.Xh=null,this.Jh=t}Qh(){return this.Jh}Nn(){var t,n;(n=(t=this.Jh).updateAllViews)==null||n.call(t)}jn(){var s,i,r;const t=((i=(s=this.Jh).paneViews)==null?void 0:i.call(s))??[];if(((r=this.Xh)==null?void 0:r.Kh)===t)return this.Xh.Gh;const n=t.map(o=>new ix(o));return this.Xh={Kh:t,Gh:n},n}Qs(t,n){var s,i;return((i=(s=this.Jh).hitTest)==null?void 0:i.call(s,t,n))??null}}let rx=class extends Yf{cn(){return[]}};class ox{constructor(t){this.jh=t}st(t,n,s){this.jh.draw(t,zr)}qh(t,n,s){var i,r;(r=(i=this.jh).drawBackground)==null||r.call(i,t,zr)}}class qh{constructor(t){this.Ls=null,this.Yh=t}Tt(){var s;const t=this.Yh.renderer();if(t===null)return null;if(((s=this.Ls)==null?void 0:s.Kh)===t)return this.Ls.Gh;const n=new ox(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}function Xf(e){var t,n,s;return{ri:e.text(),Ei:e.coordinate(),Vi:(t=e.fixedCoordinate)==null?void 0:t.call(e),R:e.textColor(),Z:e.backColor(),It:((n=e.visible)==null?void 0:n.call(e))??!0,pi:((s=e.tickVisible)==null?void 0:s.call(e))??!0}}class ax{constructor(t,n){this.Xt=new Vf,this.ta=t,this.ia=n}Tt(){return this.Xt.ht({nn:this.ia.nn(),...Xf(this.ta)}),this.Xt}}class lx extends Xr{constructor(t,n){super(),this.ta=t,this.Ki=n}Yi(t,n,s){const i=Xf(this.ta);s.Z=i.Z,t.R=i.R;const r=2/12*this.Ki.P();s.Ti=r,s.Ri=r,s.Ei=i.Ei,s.Vi=i.Vi,t.ri=i.ri,t.It=i.It,t.pi=i.pi}}class cx extends Yf{constructor(t,n){super(t),this.na=null,this.sa=null,this.ea=null,this.ra=null,this.Te=n}dn(){var i,r,o;const t=((r=(i=this.Jh).timeAxisViews)==null?void 0:r.call(i))??[];if(((o=this.na)==null?void 0:o.Kh)===t)return this.na.Gh;const n=this.Te.Qt().Et(),s=t.map(l=>new ax(l,n));return this.na={Kh:t,Gh:s},s}qn(){var i,r,o;const t=((r=(i=this.Jh).priceAxisViews)==null?void 0:r.call(i))??[];if(((o=this.sa)==null?void 0:o.Kh)===t)return this.sa.Gh;const n=this.Te.Ft(),s=t.map(l=>new lx(l,n));return this.sa={Kh:t,Gh:s},s}ha(){var s,i,r;const t=((i=(s=this.Jh).priceAxisPaneViews)==null?void 0:i.call(s))??[];if(((r=this.ea)==null?void 0:r.Kh)===t)return this.ea.Gh;const n=t.map(o=>new qh(o));return this.ea={Kh:t,Gh:n},n}aa(){var s,i,r;const t=((i=(s=this.Jh).timeAxisPaneViews)==null?void 0:i.call(s))??[];if(((r=this.ra)==null?void 0:r.Kh)===t)return this.ra.Gh;const n=t.map(o=>new qh(o));return this.ra={Kh:t,Gh:n},n}la(t,n){var s,i;return((i=(s=this.Jh).autoscaleInfo)==null?void 0:i.call(s,t,n))??null}}function lr(e,t,n,s){e.forEach(i=>{t(i).forEach(r=>{r.Zh()===n&&s.push(r)})})}function cr(e){return e.jn()}function hx(e){return e.ha()}function ux(e){return e.aa()}const dx=["Area","Line","Baseline"];class Kr extends Zv{constructor(t,n,s,i,r){super(t),this.qt=_o(),this.dr=new Hv(this),this.oa=[],this._a=new jv(this),this.ua=null,this.ca=null,this.da=null,this.fa=[],this.pa=new Kv,this.va=new Map,this.ma=null,this.yn=s,this.wa=n;const o=new qv(this);if(this.mn=[o],this.pr=new qf(o,this,t),dx.includes(this.wa)&&(this.ua=new Uv(this)),this.Ma(),this.Yh=i(this,this.Qt(),r),this.wa==="Custom"){const l=this.Yh;l.ga&&this.ba(l.ga)}}m(){this.da!==null&&clearTimeout(this.da)}We(t){return this.yn.priceLineColor||t}Ae(t){const n={Le:!0},s=this.Ft();if(this.Qt().Et().Zi()||s.Zi()||this.qt.Zi())return n;const i=this.Qt().Et().Ee(),r=this.Lt();if(i===null||r===null)return n;let o,l;if(t){const u=this.qt.kh();if(u===null)return n;o=u,l=u.$n}else{const u=this.qt.Hn(i.bi(),-1);if(u===null||(o=this.qt.Mh(u.$n),o===null))return n;l=u.$n}const c=o.Wt[3],h=this.Sa().Sh(l,{Wt:o}),a=s.Nt(c,r.Wt);return{Le:!1,Mt:c,ri:s.Ji(c,r.Wt),qe:s.xa(c),Ye:s.Ca(c,r.Wt),R:h.sh,Ei:a,$n:l}}Sa(){return this.ca!==null||(this.ca=new ex(this)),this.ca}N(){return this.yn}vr(t){const n=this.Qt(),{priceScaleId:s,visible:i,priceFormat:r}=t;s!==void 0&&s!==this.yn.priceScaleId&&n.ya(this,s),i!==void 0&&i!==this.yn.visible&&n.Pa();const o=t.conflationThresholdFactor!==void 0;$e(this.yn,t),Object.prototype.hasOwnProperty.call(t,"autoscaleInfoProvider")&&t.autoscaleInfoProvider===void 0&&(this.yn.autoscaleInfoProvider=void 0),o&&(this.va.clear(),this.Qt().mr()),r!==void 0&&(this.Ma(),n.ka()),n.Ta(this),n.Ra(),this.Yh.Pt("options")}ht(t,n){this.qt.ht(t),this.va.clear();const s=this.Qt().Et().N();s.enableConflation&&s.precomputeConflationOnInit&&this.Da(s.precomputeConflationPriority),this.Ia(),this.ua!==null&&(n&&n.Va?this.ua.De():t.length===0&&this.ua.Re());const i=this.Qt().Ks(this);this.Qt().Ba(i),this.Qt().Ta(this),this.Qt().Ra(),this.Qt().mr()}Ia(){this.Yh.Pt("data")}Ea(t){const n=new Jv(this,t);return this.oa.push(n),this.Qt().Ta(this),n}Aa(t){const n=this.oa.indexOf(t);n!==-1&&this.oa.splice(n,1),this.Qt().Ta(this)}La(){return this.oa}bh(){return this.wa}Lt(){const t=this.za();return t===null?null:{Wt:t.Wt[3],Oa:t.wt}}za(){const t=this.Qt().Et().Ee();if(t===null)return null;const n=t.Na();return this.qt.Hn(n,1)}Un(){return this.qt}ba(t){this.ma=t,this.va.clear()}Fa(){return!!this.Qt().Et().N().enableConflation&&this.Wa()>1}Rr(t){if(!this.Fa())return;const n=this.Wa();if(!this.va.has(n))return;const s=this.wa==="Custom",i=s&&this.ma||void 0,r=s&&this.Yh.Ha?c=>{const h=c,a=this.Yh.Ha(h);return Array.isArray(a)?a:[typeof a=="number"?a:0]}:void 0,o=this.pa.Rr(this.qt.Bh(),t,n,i,s,r),l=_o();l.ht(o),this.va.set(n,l)}Ua(){const t=this.Qt().Et().N().enableConflation;if(this.wa==="Custom"&&this.ma===null)return this.qt;if(!t)return this.qt;const n=this.Wa(),s=this.va.get(n);return s||(this.$a(n),this.va.get(n)??this.qt)}ja(t){const n=this.qt.Mh(t);return n===null?null:this.wa==="Bar"||this.wa==="Candlestick"||this.wa==="Custom"?{jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3]}:n.Wt[3]}qa(t){const n=[];lr(this.fa,cr,"top",n);const s=this.ua;return s!==null&&s.It()&&(this.da===null&&s.Ve()&&(this.da=setTimeout(()=>{this.da=null,this.Qt().Ya()},0)),s.Ie(),n.unshift(s)),n}jn(){const t=[];this.Ka()||t.push(this._a),t.push(this.Yh,this.dr);const n=this.oa.map(s=>s.wr());return t.push(...n),lr(this.fa,cr,"normal",t),t}Ga(){var r,o;const t=((o=(r=this.Yh).Ga)==null?void 0:o.call(r))??null;if(t===null)return null;const n=[];this.Ka()||n.push(this._a),n.push(...t.Za),lr(this.fa,cr,"normal",n);const s=[];s.push(...t.qa,this.dr);const i=this.oa.map(l=>l.wr());return s.push(...i),{Za:n,qa:s}}Xa(){return this.Ja(cr,"bottom")}Qa(t){return this.Ja(hx,t)}tl(t){return this.Ja(ux,t)}il(t,n){return this.fa.map(s=>s.Qs(t,n)).filter(s=>s!==null)}cn(){return[this.pr,...this.oa.map(t=>t.Mr())]}qn(t,n){if(n!==this.hn&&!this.Ka())return[];const s=[...this.mn];for(const i of this.oa)s.push(i.gr());return this.fa.forEach(i=>{s.push(...i.qn())}),s}dn(){const t=[];return this.fa.forEach(n=>{t.push(...n.dn())}),t}la(t,n){if(this.yn.autoscaleInfoProvider!==void 0){const s=this.yn.autoscaleInfoProvider(()=>{const i=this.nl(t,n);return i===null?null:i.sr()});return Lr.er(s)}return this.nl(t,n)}Kh(){const t=this.yn.priceFormat;return t.base??1/t.minMove}sl(){return this.el}Nn(){var t;this.Yh.Pt();for(const n of this.mn)n.Pt();for(const n of this.oa)n.Pt();this.dr.Pt(),this._a.Pt(),(t=this.ua)==null||t.Pt(),this.fa.forEach(n=>n.Nn())}Ft(){return K(super.Ft())}At(t){if(!((this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline")&&this.yn.crosshairMarkerVisible))return null;const n=this.qt.Mh(t);return n===null?null:{Mt:n.Wt[3],ft:this.rl(),Ht:this.hl(),Ot:this.al(),zt:this.ll(t)}}He(){return this.yn.title}It(){return this.yn.visible}ol(t){this.fa.push(new cx(t,this))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t)}ul(){if(this.wa==="Custom")return t=>this.Yh.Ha(t)}cl(){if(this.wa==="Custom")return t=>this.Yh.dl(t)}fl(){return this.qt.Lh()}Ka(){return!Qr(this.Ft().pl())}nl(t,n){if(!$i(t)||!$i(n)||this.qt.Zi())return null;const s=this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline"||this.wa==="Histogram"?[3]:[2,1],i=this.qt.Eh(t,n,s);let r=i!==null?new ke(i.Uh,i.$h):null,o=null;if(this.bh()==="Histogram"){const l=this.yn.base,c=new ke(l,l);r=r!==null?r.Ss(c):c}return this.fa.forEach(l=>{const c=l.la(t,n);if(c!=null&&c.priceRange){const h=new ke(c.priceRange.minValue,c.priceRange.maxValue);r=r!==null?r.Ss(h):h}c!=null&&c.margins&&(o=c.margins)}),new Lr(r,o)}rl(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerRadius}return 0}hl(){switch(this.wa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBorderColor;if(t.length!==0)return t}}return null}al(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerBorderWidth}return 0}ll(t){switch(this.wa){case"Line":case"Area":case"Baseline":{const n=this.yn.crosshairMarkerBackgroundColor;if(n.length!==0)return n}}return this.Sa().Sh(t).sh}Ma(){switch(this.yn.priceFormat.type){case"custom":{const t=this.yn.priceFormat.formatter;this.el={format:t,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(n=>n.map(t))};break}case"volume":this.el=new zv(this.yn.priceFormat.precision);break;case"percent":this.el=new Hf(this.yn.priceFormat.precision);break;default:{const t=Math.pow(10,this.yn.priceFormat.precision);this.el=new Jr(t,this.yn.priceFormat.minMove*t)}}this.hn!==null&&this.hn.vl()}Ja(t,n){const s=[];return lr(this.fa,t,n,s),s}Wa(){const{ml:t,wl:n,Ml:s}=this.gl();return this.pa.Sr(t,n,s)}gl(){const t=this.Qt().Et(),n=t.ml(),s=window.devicePixelRatio||1,i=t.N().conflationThresholdFactor;return{ml:n,wl:s,Ml:this.yn.conflationThresholdFactor??i??1}}bl(t){const n=this.qt.Bh();let s;if(this.wa==="Custom"&&this.ma!==null){const r=this.ul();if(!r)throw new Error(Yv);s=this.pa.Cr(n,t,this.ma,!0,o=>r(o))}else s=this.pa.Cr(n,t);const i=_o();return i.ht(s),i}$a(t){const n=this.bl(t);this.va.set(t,n)}Da(t){var s;if(this.wa==="Custom"&&(this.ma===null||!this.ul()))return;this.va.clear();const n=this.Qt().Et().Sl();for(const i of n){const r=()=>{this.xl(i)},o=typeof window=="object"&&window||typeof self=="object"&&self;(s=o==null?void 0:o.yl)!=null&&s.Cl?o.yl.Cl(()=>{r()},{se:t}):Promise.resolve().then(()=>r())}}xl(t){if(this.va.has(t)||this.qt.Bh().length===0)return;const n=this.bl(t);this.va.set(t,n)}}const fx=[3],mx=[0,1,2,3];class px{constructor(t){this.yn=t}Pl(t,n,s){let i=t;if(this.yn.mode===0)return i;const r=s.kn(),o=r.Lt();if(o===null)return i;const l=r.Nt(t,o),c=s.kl().filter(a=>a instanceof Kr).reduce((a,u)=>{if(s.Gs(u)||!u.It())return a;const f=u.Ft(),p=u.Un();if(f.Zi()||!p.ze(n))return a;const g=p.Mh(n);if(g===null)return a;const d=Mn(u.Lt()),w=this.yn.mode===3?mx:fx;return a.concat(w.map(C=>f.Nt(g.Wt[C],d.Wt)))},[]);if(c.length===0)return i;c.sort((a,u)=>Math.abs(a-l)-Math.abs(u-l));const h=c[0];return i=r.Tn(h,o),i}}function Ls(e,t,n){return Math.min(Math.max(e,t),n)}function hr(e,t,n){return t-e<=n}class gx extends Nn{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(o,l){o.save(),o.lineWidth%2&&o.translate(.5,.5),l(),o.restore()}(t,()=>{const o=K(this.qt);if(o.Tl){t.strokeStyle=o.Rl,_n(t,o.Dl),t.beginPath();for(const l of o.Il){const c=Math.round(l.Vl*s);t.moveTo(c,-r),t.lineTo(c,n.height+r)}t.stroke()}if(o.Bl){t.strokeStyle=o.El,_n(t,o.Al),t.beginPath();for(const l of o.Ll){const c=Math.round(l.Vl*i);t.moveTo(-r,c),t.lineTo(n.width+r,c)}t.stroke()}})}}class yx{constructor(t){this.Xt=new gx,this.xt=!0,this.yt=t}Pt(){this.xt=!0}Tt(){if(this.xt){const t=this.yt.Qt().N().grid,n={Bl:t.horzLines.visible,Tl:t.vertLines.visible,El:t.horzLines.color,Rl:t.vertLines.color,Al:t.horzLines.style,Dl:t.vertLines.style,Ll:this.yt.kn().zl(),Il:(this.yt.Qt().Et().zl()||[]).map(s=>({Vl:s.coord}))};this.Xt.ht(n),this.xt=!1}return this.Xt}}class bx{constructor(t){this.Yh=new yx(t)}wr(){return this.Yh}}const $o={Ol:4,Nl:1e-4};function Ns(e,t){const n=100*(e-t)/t;return t<0?-n:n}function vx(e,t){const n=Ns(e.Je(),t),s=Ns(e.Qe(),t);return new ke(n,s)}function xi(e,t){const n=100*(e-t)/t+100;return t<0?-n:n}function xx(e,t){const n=xi(e.Je(),t),s=xi(e.Qe(),t);return new ke(n,s)}function Fr(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const s=Math.log10(n+t.Nl)+t.Ol;return e<0?-s:s}function wi(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const s=Math.pow(10,n-t.Ol)-t.Nl;return e<0?-s:s}function ai(e,t){if(e===null)return null;const n=Fr(e.Je(),t),s=Fr(e.Qe(),t);return new ke(n,s)}function Is(e,t){if(e===null)return null;const n=wi(e.Je(),t),s=wi(e.Qe(),t);return new ke(n,s)}function No(e){if(e===null)return $o;const t=Math.abs(e.Qe()-e.Je());if(t>=1||t<1e-15)return $o;const n=Math.ceil(Math.abs(Math.log10(t))),s=$o.Ol+n;return{Ol:s,Nl:1/Math.pow(10,s)}}class Io{constructor(t,n){if(this.Fl=t,this.Wl=n,function(s){if(s<0)return!1;if(s>1e18)return!0;for(let i=s;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Fl))this.Hl=[2,2.5,2];else{this.Hl=[];for(let s=this.Fl;s!==1;){if(s%2==0)this.Hl.push(2),s/=2;else{if(s%5!=0)throw new Error("unexpected base");this.Hl.push(2,2.5),s/=5}if(this.Hl.length>100)throw new Error("something wrong with base")}}}Ul(t,n,s){const i=this.Fl===0?0:1/this.Fl;let r=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-n)))),o=0,l=this.Wl[0];for(;;){const u=hr(r,i,1e-14)&&r>i+1e-14,f=hr(r,s*l,1e-14),p=hr(r,1,1e-14);if(!(u&&f&&p))break;r/=l,l=this.Wl[++o%this.Wl.length]}if(r<=i+1e-14&&(r=i),r=Math.max(1,r),this.Hl.length>0&&(c=r,h=1,a=1e-14,Math.abs(c-h)<a))for(o=0,l=this.Hl[0];hr(r,s*l,1e-14)&&r>i+1e-14;)r/=l,l=this.Hl[++o%this.Hl.length];var c,h,a;return r}}class Gh{constructor(t,n,s,i){this.$l=[],this.Ki=t,this.Fl=n,this.jl=s,this.ql=i}Ul(t,n){if(t<n)throw new Error("high < low");const s=this.Ki.$t(),i=(t-n)*this.Yl()/s,r=new Io(this.Fl,[2,2.5,2]),o=new Io(this.Fl,[2,2,2.5]),l=new Io(this.Fl,[2.5,2,2]),c=[];return c.push(r.Ul(t,n,i),o.Ul(t,n,i),l.Ul(t,n,i)),function(h){if(h.length<1)throw Error("array is empty");let a=h[0];for(let u=1;u<h.length;++u)h[u]<a&&(a=h[u]);return a}(c)}Kl(){const t=this.Ki,n=t.Lt();if(n===null)return void(this.$l=[]);const s=t.$t(),i=this.jl(s-1,n),r=this.jl(0,n),o=this.Ki.N().entireTextOnly?this.Gl()/2:0,l=o,c=s-1-o,h=Math.max(i,r),a=Math.min(i,r);if(h===a)return void(this.$l=[]);const u=this.Ul(h,a);if(this.Zl(n,u,h,a,l,c),t.Xl()&&this.Jl(u,a,h)){const g=this.Ki.Ql();this.io(n,u,l,c,g,2*g)}const f=this.$l.map(g=>g.no),p=this.Ki.so(f);for(let g=0;g<this.$l.length;g++)this.$l[g].eo=p[g]}zl(){return this.$l}Gl(){return this.Ki.P()}Yl(){return Math.ceil(this.Gl()*this.Ki.N().tickMarkDensity)}Zl(t,n,s,i,r,o){const l=this.$l,c=this.Ki;let h=s%n;h+=h<0?n:0;const a=s>=i?1:-1;let u=null,f=0;for(let p=s-h;p>i;p-=n){const g=this.ql(p,t,!0);u!==null&&Math.abs(g-u)<this.Yl()||g<r||g>o||(f<l.length?(l[f].Vl=g,l[f].eo=c.ro(p),l[f].no=p):l.push({Vl:g,eo:c.ro(p),no:p}),f++,u=g,c.ho()&&(n=this.Ul(p*a,i)))}l.length=f}io(t,n,s,i,r,o){const l=this.$l,c=this.ao(t,s,r,o),h=this.ao(t,i,-o,-r),a=this.ql(0,t,!0)-this.ql(n,t,!0);l.length>0&&l[0].Vl-c.Vl<a/2&&l.shift(),l.length>0&&h.Vl-l[l.length-1].Vl<a/2&&l.pop(),l.unshift(c),l.push(h)}ao(t,n,s,i){const r=(s+i)/2,o=this.jl(n+s,t),l=this.jl(n+i,t),c=Math.min(o,l),h=Math.max(o,l),a=Math.max(.1,this.Ul(h,c)),u=this.jl(n+r,t),f=u-u%a,p=this.ql(f,t,!0);return{eo:this.Ki.ro(f),Vl:p,no:f}}Jl(t,n,s){let i=Mn(this.Ki.ar());return this.Ki.ho()&&(i=Is(i,this.Ki.lo())),i.Je()-n<t&&s-i.Qe()<t}}function Qf(e){return e.slice().sort((t,n)=>K(t.ln())-K(n.ln()))}var Yh;(function(e){e[e.Normal=0]="Normal",e[e.Logarithmic=1]="Logarithmic",e[e.Percentage=2]="Percentage",e[e.IndexedTo100=3]="IndexedTo100"})(Yh||(Yh={}));const Xh=new Hf,Qh=new Jr(100,1);class wx{constructor(t,n,s,i,r){this.oo=0,this._o=null,this.rr=null,this.uo=null,this.co={do:!1,fo:null},this.po=!1,this.vo=0,this.mo=0,this.wo=new Zt,this.Mo=new Zt,this.bo=[],this.So=null,this.xo=null,this.Co=null,this.yo=null,this.Po=null,this.el=Qh,this.ko=No(null),this.To=t,this.yn=n,this.Ro=s,this.Do=i,this.Io=r,this.Vo=new Gh(this,100,this.Bo.bind(this),this.Eo.bind(this))}pl(){return this.To}N(){return this.yn}vr(t){if($e(this.yn,t),this.vl(),t.mode!==void 0&&this.Ao({_e:t.mode}),t.scaleMargins!==void 0){const n=Re(t.scaleMargins.top),s=Re(t.scaleMargins.bottom);if(n<0||n>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${n}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(n+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${n+s}`);this.Lo(),this.Co=null}}zo(){return this.yn.autoScale}Oo(){return this.po}ho(){return this.yn.mode===1}je(){return this.yn.mode===2}No(){return this.yn.mode===3}lo(){return this.ko}_e(){return{hs:this.yn.autoScale,Fo:this.yn.invertScale,_e:this.yn.mode}}Ao(t){const n=this._e();let s=null;t.hs!==void 0&&(this.yn.autoScale=t.hs),t._e!==void 0&&(this.yn.mode=t._e,t._e!==2&&t._e!==3||(this.yn.autoScale=!0),this.co.do=!1),n._e===1&&t._e!==n._e&&(function(r,o){if(r===null)return!1;const l=wi(r.Je(),o),c=wi(r.Qe(),o);return isFinite(l)&&isFinite(c)}(this.rr,this.ko)?(s=Is(this.rr,this.ko),s!==null&&this.Wo(s)):this.yn.autoScale=!0),t._e===1&&t._e!==n._e&&(s=ai(this.rr,this.ko),s!==null&&this.Wo(s));const i=n._e!==this.yn.mode;i&&(n._e===2||this.je())&&this.vl(),i&&(n._e===3||this.No())&&this.vl(),t.Fo!==void 0&&n.Fo!==t.Fo&&(this.yn.invertScale=t.Fo,this.Ho()),this.Mo.p(n,this._e())}Uo(){return this.Mo}P(){return this.Ro.fontSize}$t(){return this.oo}$o(t){this.oo!==t&&(this.oo=t,this.Lo(),this.Co=null)}jo(){if(this._o)return this._o;const t=this.$t()-this.qo()-this.Yo();return this._o=t,t}ar(){return this.Ko(),this.rr}Wo(t,n){const s=this.rr;(n||s===null&&t!==null||s!==null&&!s.Ze(t))&&(this.Co=null,this.rr=t)}Go(t){this.Wo(t),this.Zo(t!==null)}Zi(){return this.Ko(),this.oo===0||!this.rr||this.rr.Zi()}Xo(t){return this.Fo()?t:this.$t()-1-t}Nt(t,n){return this.je()?t=Ns(t,n):this.No()&&(t=xi(t,n)),this.Eo(t,n)}Jo(t,n,s){this.Ko();const i=this.Yo(),r=K(this.ar()),o=r.Je(),l=r.Qe(),c=this.jo()-1,h=this.Fo(),a=c/(l-o),u=s===void 0?0:s.from,f=s===void 0?t.length:s.to,p=this.Qo();for(let g=u;g<f;g++){const d=t[g],w=d.Mt;if(isNaN(w))continue;let C=w;p!==null&&(C=p(d.Mt,n));const x=i+a*(C-o),k=h?x:this.oo-1-x;d.ut=k}}t_(t,n,s){this.Ko();const i=this.Yo(),r=K(this.ar()),o=r.Je(),l=r.Qe(),c=this.jo()-1,h=this.Fo(),a=c/(l-o),u=s===void 0?0:s.from,f=s===void 0?t.length:s.to,p=this.Qo();for(let g=u;g<f;g++){const d=t[g];let w=d.jr,C=d.qr,x=d.Yr,k=d.Kr;p!==null&&(w=p(d.jr,n),C=p(d.qr,n),x=p(d.Yr,n),k=p(d.Kr,n));let S=i+a*(w-o),T=h?S:this.oo-1-S;d.i_=T,S=i+a*(C-o),T=h?S:this.oo-1-S,d.n_=T,S=i+a*(x-o),T=h?S:this.oo-1-S,d.s_=T,S=i+a*(k-o),T=h?S:this.oo-1-S,d.e_=T}}Tn(t,n){const s=this.Bo(t,n);return this.r_(s,n)}r_(t,n){let s=t;return this.je()?s=function(i,r){return r<0&&(i=-i),i/100*r+r}(s,n):this.No()&&(s=function(i,r){return i-=100,r<0&&(i=-i),i/100*r+r}(s,n)),s}kl(){return this.bo}Dt(){return this.xo||(this.xo=Qf(this.bo)),this.xo}h_(t){this.bo.indexOf(t)===-1&&(this.bo.push(t),this.vl(),this.a_())}l_(t){const n=this.bo.indexOf(t);if(n===-1)throw new Error("source is not attached to scale");this.bo.splice(n,1),this.bo.length===0&&(this.Ao({hs:!0}),this.Wo(null)),this.vl(),this.a_()}Lt(){let t=null;for(const n of this.bo){const s=n.Lt();s!==null&&(t===null||s.Oa<t.Oa)&&(t=s)}return t===null?null:t.Wt}Fo(){return this.yn.invertScale}zl(){const t=this.Lt()===null;if(this.Co!==null&&(t||this.Co.o_===t))return this.Co.zl;this.Vo.Kl();const n=this.Vo.zl();return this.Co={zl:n,o_:t},this.wo.p(),n}__(){return this.wo}u_(t){this.je()||this.No()||this.yo===null&&this.uo===null&&(this.Zi()||(this.yo=this.oo-t,this.uo=K(this.ar()).Xe()))}c_(t){if(this.je()||this.No()||this.yo===null)return;this.Ao({hs:!1}),(t=this.oo-t)<0&&(t=0);let n=(this.yo+.2*(this.oo-1))/(t+.2*(this.oo-1));const s=K(this.uo).Xe();n=Math.max(n,.1),s.ir(n),this.Wo(s)}d_(){this.je()||this.No()||(this.yo=null,this.uo=null)}f_(t){this.zo()||this.Po===null&&this.uo===null&&(this.Zi()||(this.Po=t,this.uo=K(this.ar()).Xe()))}p_(t){if(this.zo()||this.Po===null)return;const n=K(this.ar()).tr()/(this.jo()-1);let s=t-this.Po;this.Fo()&&(s*=-1);const i=s*n,r=K(this.uo).Xe();r.nr(i),this.Wo(r,!0),this.Co=null}v_(){this.zo()||this.Po!==null&&(this.Po=null,this.uo=null)}sl(){return this.el||this.vl(),this.el}Ji(t,n){switch(this.yn.mode){case 2:return this.m_(Ns(t,n));case 3:return this.sl().format(xi(t,n));default:return this.cr(t)}}ro(t){switch(this.yn.mode){case 2:return this.m_(t);case 3:return this.sl().format(t);default:return this.cr(t)}}so(t){switch(this.yn.mode){case 2:return this.w_(t);case 3:return this.sl().formatTickmarks(t);default:return this.M_(t)}}xa(t){return this.cr(t,K(this.So).sl())}Ca(t,n){return t=Ns(t,n),this.m_(t,Xh)}g_(){return this.bo}b_(t){this.co={fo:t,do:!1}}Nn(){this.bo.forEach(t=>t.Nn())}Xl(){return this.yn.ensureEdgeTickMarksVisible&&this.zo()}Ql(){return this.P()/2}vl(){this.Co=null;let t=1/0;this.So=null;for(const s of this.bo)s.ln()<t&&(t=s.ln(),this.So=s);let n=100;this.So!==null&&(n=Math.round(this.So.Kh())),this.el=Qh,this.je()?(this.el=Xh,n=100):this.No()?(this.el=new Jr(100,1),n=100):this.So!==null&&(this.el=this.So.sl()),this.Vo=new Gh(this,n,this.Bo.bind(this),this.Eo.bind(this)),this.Vo.Kl()}a_(){this.xo=null}S_(){return this.So===null||this.je()||this.No()?1:1/this.So.Kh()}Xi(){return this.Io}Zo(t){this.po=t}qo(){return this.Fo()?this.yn.scaleMargins.bottom*this.$t()+this.mo:this.yn.scaleMargins.top*this.$t()+this.vo}Yo(){return this.Fo()?this.yn.scaleMargins.top*this.$t()+this.vo:this.yn.scaleMargins.bottom*this.$t()+this.mo}Ko(){this.co.do||(this.co.do=!0,this.x_())}Lo(){this._o=null}Eo(t,n){if(this.Ko(),this.Zi())return 0;t=this.ho()&&t?Fr(t,this.ko):t;const s=K(this.ar()),i=this.Yo()+(this.jo()-1)*(t-s.Je())/s.tr();return this.Xo(i)}Bo(t,n){if(this.Ko(),this.Zi())return 0;const s=this.Xo(t),i=K(this.ar()),r=i.Je()+i.tr()*((s-this.Yo())/(this.jo()-1));return this.ho()?wi(r,this.ko):r}Ho(){this.Co=null,this.Vo.Kl()}x_(){if(this.Oo()&&!this.zo())return;const t=this.co.fo;if(t===null)return;let n=null;const s=this.g_();let i=0,r=0;for(const c of s){if(!c.It())continue;const h=c.Lt();if(h===null)continue;const a=c.la(t.Na(),t.bi());let u=a&&a.ar();if(u!==null){switch(this.yn.mode){case 1:u=ai(u,this.ko);break;case 2:u=vx(u,h.Wt);break;case 3:u=xx(u,h.Wt)}if(n=n===null?u:n.Ss(K(u)),a!==null){const f=a.lr();f!==null&&(i=Math.max(i,f.above),r=Math.max(r,f.below))}}}if(this.Xl()&&(i=Math.max(i,this.Ql()),r=Math.max(r,this.Ql())),i===this.vo&&r===this.mo||(this.vo=i,this.mo=r,this.Co=null,this.Lo()),n!==null){if(n.Je()===n.Qe()){const c=5*this.S_();this.ho()&&(n=Is(n,this.ko)),n=new ke(n.Je()-c,n.Qe()+c),this.ho()&&(n=ai(n,this.ko))}if(this.ho()){const c=Is(n,this.ko),h=No(c);if(o=h,l=this.ko,o.Ol!==l.Ol||o.Nl!==l.Nl){const a=this.uo!==null?Is(this.uo,this.ko):null;this.ko=h,n=ai(c,h),a!==null&&(this.uo=ai(a,h))}}this.Wo(n)}else this.rr===null&&(this.Wo(new ke(-.5,.5)),this.ko=No(null));var o,l}Qo(){return this.je()?Ns:this.No()?xi:this.ho()?t=>Fr(t,this.ko):null}C_(t,n,s){return n===void 0?(s===void 0&&(s=this.sl()),s.format(t)):n(t)}y_(t,n,s){return n===void 0?(s===void 0&&(s=this.sl()),s.formatTickmarks(t)):n(t)}cr(t,n){return this.C_(t,this.Do.priceFormatter,n)}M_(t,n){const s=this.Do.priceFormatter;return this.y_(t,this.Do.tickmarksPriceFormatter??(s?i=>i.map(s):void 0),n)}m_(t,n){return this.C_(t,this.Do.percentageFormatter,n)}w_(t,n){const s=this.Do.percentageFormatter;return this.y_(t,this.Do.tickmarksPercentageFormatter??(s?i=>i.map(s):void 0),n)}}function Jh(e){return e instanceof Kr}class va{constructor(t,n){this.bo=[],this.P_=new Map,this.oo=0,this.k_=0,this.T_=1,this.xo=null,this.R_=null,this.D_=!1,this.I_=new Zt,this.fa=[],this.ia=t,this.sn=n,this.V_=new bx(this);const s=n.N();this.B_=this.E_("left",s.leftPriceScale),this.A_=this.E_("right",s.rightPriceScale),this.B_.Uo().i(this.L_.bind(this,this.B_),this),this.A_.Uo().i(this.L_.bind(this,this.A_),this),this.z_(s)}z_(t){if(t.leftPriceScale&&this.B_.vr(t.leftPriceScale),t.rightPriceScale&&this.A_.vr(t.rightPriceScale),t.localization&&(this.B_.vl(),this.A_.vl()),t.overlayPriceScales){const n=Array.from(this.P_.values());for(const s of n){const i=K(s[0].Ft());i.vr(t.overlayPriceScales),t.localization&&i.vl()}}}O_(t){switch(t){case"left":return this.B_;case"right":return this.A_}return this.P_.has(t)?Re(this.P_.get(t))[0].Ft():null}m(){this.Qt().N_().u(this),this.B_.Uo().u(this),this.A_.Uo().u(this),this.bo.forEach(t=>{t.m&&t.m()}),this.fa=this.fa.filter(t=>{const n=t.Qh();return n.detached&&n.detached(),!1}),this.I_.p()}F_(){return this.T_}W_(t){this.T_=t}Qt(){return this.sn}nn(){return this.k_}$t(){return this.oo}H_(t){this.k_=t,this.U_()}$o(t){this.oo=t,this.B_.$o(t),this.A_.$o(t),this.bo.forEach(n=>{if(this.Gs(n)){const s=n.Ft();s!==null&&s.$o(t)}}),this.U_()}j_(t){this.D_=t}q_(){return this.D_}Y_(){return this.bo.filter(Jh)}kl(){return this.bo}Gs(t){const n=t.Ft();return n===null||this.B_!==n&&this.A_!==n}h_(t,n,s){this.K_(t,n,s?t.ln():this.bo.length)}l_(t,n){const s=this.bo.indexOf(t);pe(s!==-1,"removeDataSource: invalid data source"),this.bo.splice(s,1),n||this.bo.forEach((o,l)=>o._n(l));const i=K(t.Ft()).pl();if(this.P_.has(i)){const o=Re(this.P_.get(i)),l=o.indexOf(t);l!==-1&&(o.splice(l,1),o.length===0&&this.P_.delete(i))}const r=t.Ft();r&&r.kl().indexOf(t)>=0&&(r.l_(t),this.G_(r)),this.Z_()}Xs(t){return t===this.B_?"left":t===this.A_?"right":"overlay"}X_(){return this.B_}J_(){return this.A_}Q_(t,n){t.u_(n)}tu(t,n){t.c_(n),this.U_()}iu(t){t.d_()}nu(t,n){t.f_(n)}su(t,n){t.p_(n),this.U_()}eu(t){t.v_()}U_(){this.bo.forEach(t=>{t.Nn()})}kn(){const[t,n]=this.ru();let s=null;return t.N().visible&&t.kl().length!==0?s=t:n.N().visible&&n.kl().length!==0?s=n:this.bo.length!==0&&(s=this.bo[0].Ft()),s===null&&(s=this.Zs()??t),s}Zs(){const[t,n]=this.ru();return t.N().visible?t:n.N().visible?n:null}G_(t){t!==null&&t.zo()&&this.hu(t)}au(t){const n=this.ia.Ee();t.Ao({hs:!0}),n!==null&&t.b_(n),this.U_()}lu(){this.hu(this.B_),this.hu(this.A_)}ou(){this.G_(this.B_),this.G_(this.A_),this.bo.forEach(t=>{this.Gs(t)&&this.G_(t.Ft())}),this.U_(),this.sn.mr()}Dt(){return this.xo===null&&(this.xo=Qf(this.bo)),this.xo}_u(){var o;const t=this.Dt(),n=(o=this.sn.cu())==null?void 0:o.uu,s=this.sn.N().hoveredSeriesOnTop,i=this.R_;if(i!==null&&i.Kh===t&&i.du===n&&i.fu===s)return i.pu;const r=function(l,c,h){if(!h)return l;const a=l.indexOf(c);if(a===-1||a===l.length-1)return l;const u=[];for(let f=0;f<l.length;f++)f!==a&&u.push(l[f]);return u.push(l[a]),u}(t,n,s);return this.R_={Kh:t,du:n,fu:s,pu:r},r}vu(t,n){n=Ls(n,0,this.bo.length-1);const s=this.bo.indexOf(t);pe(s!==-1,"setSeriesOrder: invalid data source"),this.bo.splice(s,1),this.bo.splice(n,0,t),this.bo.forEach((i,r)=>i._n(r)),this.Z_();for(const i of[this.B_,this.A_])i.a_(),i.vl();this.sn.mr()}Vt(){return this.Dt().filter(Jh)}mu(){return this.I_}wu(){return this.V_}ol(t){this.fa.push(new rx(t))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t),t.detached&&t.detached(),this.sn.mr()}Mu(){return this.fa}il(t,n){return this.fa.map(s=>s.Qs(t,n)).filter(s=>s!==null)}hu(t){const n=t.g_();if(n&&n.length>0&&!this.ia.Zi()){const s=this.ia.Ee();s!==null&&t.b_(s)}t.Nn()}K_(t,n,s){let i=this.O_(n);if(i===null&&(i=this.E_(n,this.sn.N().overlayPriceScales)),this.bo.splice(s,0,t),!Qr(n)){const r=this.P_.get(n)||[];r.push(t),this.P_.set(n,r)}t._n(s),i.h_(t),t.un(i),this.G_(i),this.Z_()}Z_(){this.xo=null,this.R_=null}ru(){return this.sn.N().defaultVisiblePriceScaleId==="left"?[this.B_,this.A_]:[this.A_,this.B_]}L_(t,n,s){n._e!==s._e&&this.hu(t)}E_(t,n){const s={visible:!0,autoScale:!0,...an(n)},i=new wx(t,s,this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return i.$o(this.$t()),i}}function xa(e,t){return t===null||e.se===2&&t.se!==2||(t.se!==2||e.se===2)&&e.ne!==t.ne&&e.ne<t.ne}function Jf(e){return{te:e.te,ie:e.ie}}function Sx(e){return{ne:e.distance??0,se:e.hitTestPriority??(e.itemType==="marker"?2:0),ee:e.itemType??"primitive",gu:e.cursorStyle,te:e.externalId}}function ur(e){return{uu:e.uu,bu:Jf(e.Su),gu:e.Su.gu,ee:e.Su.ee??"primitive"}}function Cx(e,t,n,s){var r;let i=null;for(const o of e){let l=((r=o.Qs)==null?void 0:r.call(o,t,n,s))??null;if(l===null){const c=o.Tt(s);l=c!==null&&c.Qs?c.Qs(t,n):null}if(l!==null){const c={xu:o,Su:l};(i===null||xa(c.Su,i.Su))&&(i=c)}}return i}function kx(e){return e.jn!==void 0}function Kf(e,t,n){const s=[e,...e.Dt()].reverse(),i=function(l,c,h){var d;let a,u,f;for(const w of l){const C=((d=w.il)==null?void 0:d.call(w,c,h))??[];for(const x of C){const k=Sx(x);p=x.zOrder,g=a==null?void 0:a.zOrder,(!g||p==="top"&&g!=="top"||p==="normal"&&g==="bottom"||x.zOrder===(a==null?void 0:a.zOrder)&&u!==void 0&&xa(k,u)||x.zOrder===(a==null?void 0:a.zOrder)&&u===void 0)&&(a=x,u=k,f=w)}}var p,g;return a&&f&&u?{Su:u,Cu:a,uu:f}:null}(s,t,n);if((i==null?void 0:i.Cu.zOrder)==="top")return ur(i);let r=null,o=null;for(const l of s){if(i&&i.uu===l&&i.Cu.zOrder!=="bottom"&&!i.Cu.isBackground)return r??ur(i);if(kx(l)){const c=Cx(l.jn(e),t,n,e);if(c!==null){const h={uu:l,xu:c.xu,bu:Jf(c.Su),gu:c.Su.gu,ee:c.Su.ee??"primitive"};(r===null||xa(c.Su,o))&&(r=h,o=c.Su)}}if(i&&i.uu===l&&i.Cu.zOrder!=="bottom"&&i.Cu.isBackground)return r??ur(i)}return r!==null?r:i!=null&&i.Cu?ur(i):null}class Mx{constructor(t,n,s=50){this.Vs=0,this.Bs=1,this.Es=1,this.Ls=new Map,this.As=new Map,this.yu=t,this.Pu=n,this.zs=s}ku(t){const n=t.time,s=this.Pu.cacheKey(n),i=this.Ls.get(s);if(i!==void 0)return i.Tu;if(this.Vs===this.zs){const o=this.As.get(this.Es);this.As.delete(this.Es),this.Ls.delete(Re(o)),this.Es++,this.Vs--}const r=this.yu(t);return this.Ls.set(s,{Tu:r,Ws:this.Bs}),this.As.set(this.Bs,s),this.Vs++,this.Bs++,r}}class Si{constructor(t,n){pe(t<=n,"right should be >= left"),this.Ru=t,this.Du=n}Na(){return this.Ru}bi(){return this.Du}Iu(){return this.Du-this.Ru+1}ze(t){return this.Ru<=t&&t<=this.Du}Ze(t){return this.Ru===t.Na()&&this.Du===t.bi()}}function Kh(e,t){return e===null||t===null?e===t:e.Ze(t)}class Ex{constructor(){this.Vu=new Map,this.Ls=null,this.Bu=!1}Eu(t){this.Bu=t,this.Ls=null}Au(t,n){this.Lu(n),this.Ls=null;for(let s=n;s<t.length;++s){const i=t[s];let r=this.Vu.get(i.timeWeight);r===void 0&&(r=[],this.Vu.set(i.timeWeight,r)),r.push({index:s,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}zu(t,n,s,i,r){const o=Math.ceil(n/t);return this.Ls!==null&&this.Ls.Ou===o&&r===this.Ls.Nu&&s===this.Ls.Fu||(this.Ls={Nu:r,Fu:s,zl:this.Wu(o,s,i),Ou:o}),this.Ls.zl}Lu(t){if(t===0)return void this.Vu.clear();const n=[];this.Vu.forEach((s,i)=>{t<=s[0].index?n.push(i):s.splice(es(s,t,r=>r.index<t),1/0)});for(const s of n)this.Vu.delete(s)}Wu(t,n,s){let i=[];const r=o=>!n||s.has(o.index);for(const o of Array.from(this.Vu.keys()).sort((l,c)=>c-l)){if(!this.Vu.get(o))continue;const l=i;i=[];const c=l.length;let h=0;const a=Re(this.Vu.get(o)),u=a.length;let f=1/0,p=-1/0;for(let g=0;g<u;g++){const d=a[g],w=d.index;for(;h<c;){const C=l[h],x=C.index;if(!(x<w&&r(C))){f=x;break}h++,i.push(C),p=x,f=1/0}if(f-w>=t&&w-p>=t&&r(d))i.push(d),p=w;else if(this.Bu)return l}for(;h<c;h++)r(l[h])&&i.push(l[h])}return i}}class zs{constructor(t){this.Hu=t}Uu(){return this.Hu===null?null:new Si(Math.floor(this.Hu.Na()),Math.ceil(this.Hu.bi()))}$u(){return this.Hu}static ju(){return new zs(null)}}function Tx(e,t){return e.weight>t.weight?e:t}class Ax{constructor(t,n,s,i){this.k_=0,this.qu=null,this.Yu=[],this.Po=null,this.yo=null,this.Ku=new Ex,this.Gu=new Map,this.Zu=zs.ju(),this.Xu=!0,this.Ju=new Zt,this.Qu=new Zt,this.tc=new Zt,this.nc=null,this.sc=null,this.ec=new Map,this.rc=-1,this.hc=[],this.ac=1,this.yn=n,this.Do=s,this.lc=n.rightOffset,this.oc=n.barSpacing,this.sn=t,this._c(n),this.Pu=i,this.uc(),this.Ku.Eu(n.uniformDistribution),this.cc(),this.dc()}N(){return this.yn}fc(t){$e(this.Do,t),this.vc(),this.uc()}vr(t,n){$e(this.yn,t),this.yn.fixLeftEdge&&this.mc(),this.yn.fixRightEdge&&this.wc(),t.barSpacing!==void 0&&this.sn.Ms(t.barSpacing),t.rightOffset!==void 0&&this.sn.gs(t.rightOffset),this._c(t),t.minBarSpacing===void 0&&t.maxBarSpacing===void 0||this.sn.Ms(t.barSpacing??this.oc),t.ignoreWhitespaceIndices!==void 0&&t.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this.dc(),this.vc(),this.uc(),t.enableConflation===void 0&&t.conflationThresholdFactor===void 0||this.cc(),this.tc.p()}Rn(t){var n;return((n=this.Yu[t])==null?void 0:n.time)??null}en(t){return this.Yu[t]??null}Mc(t,n){if(this.Yu.length<1)return null;if(this.Pu.key(t)>this.Pu.key(this.Yu[this.Yu.length-1].time))return n?this.Yu.length-1:null;const s=es(this.Yu,this.Pu.key(t),(i,r)=>this.Pu.key(i.time)<r);return this.Pu.key(t)<this.Pu.key(this.Yu[s].time)?n?s:null:s}Zi(){return this.k_===0||this.Yu.length===0||this.qu===null}gc(){return this.Yu.length>0}Ee(){return this.bc(),this.Zu.Uu()}Sc(){return this.bc(),this.Zu.$u()}xc(){const t=this.Ee();if(t===null)return null;const n={from:t.Na(),to:t.bi()};return this.Cc(n)}Cc(t){const n=Math.round(t.from),s=Math.round(t.to),i=K(this.yc()),r=K(this.Pc());return{from:K(this.en(Math.max(i,n))),to:K(this.en(Math.min(r,s)))}}kc(t){return{from:K(this.Mc(t.from,!0)),to:K(this.Mc(t.to,!0))}}nn(){return this.k_}H_(t){if(!isFinite(t)||t<=0||this.k_===t)return;const n=this.Sc(),s=this.k_;if(this.k_=t,this.Xu=!0,this.yn.lockVisibleTimeRangeOnResize&&s!==0){const i=this.oc*t/s;this.oc=i}if(this.yn.fixLeftEdge&&n!==null&&n.Na()<=0){const i=s-t;this.lc-=Math.round(i/this.oc)+1,this.Xu=!0}this.Tc(),this.Rc()}jt(t){if(this.Zi()||!$i(t))return 0;const n=this.Dc()+this.lc-t;return this.k_-(n+.5)*this.oc-1}Ic(t,n){const s=this.Dc(),i=n===void 0?0:n.from,r=n===void 0?t.length:n.to;for(let o=i;o<r;o++){const l=t[o].wt,c=s+this.lc-l,h=this.k_-(c+.5)*this.oc-1;t[o]._t=h}}Vc(t,n){const s=Math.ceil(this.Bc(t));return n&&this.yn.ignoreWhitespaceIndices&&!this.Ec(s)?this.Ac(s):s}gs(t){this.Xu=!0,this.lc=t,this.Rc(),this.sn.Lc(),this.sn.mr()}ml(){return this.oc}Ms(t){const n=this.oc;if(this.zc(t),this.yn.rightOffsetPixels!==void 0&&n!==0){const s=this.lc*n/this.oc;this.lc=s}this.Rc(),this.sn.Lc(),this.sn.mr()}Oc(){return this.lc}zl(){if(this.Zi())return null;if(this.sc!==null)return this.sc;const t=this.oc,n=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),s=Math.round(n/t),i=K(this.Ee()),r=Math.max(i.Na(),i.Na()-s),o=Math.max(i.bi(),i.bi()-s),l=this.Ku.zu(t,n,this.yn.ignoreWhitespaceIndices,this.ec,this.rc),c=this.yc()+s,h=this.Pc()-s,a=this.Nc(),u=this.yn.fixLeftEdge||a,f=this.yn.fixRightEdge||a;let p=0;for(const g of l){if(!(r<=g.index&&g.index<=o))continue;let d;p<this.hc.length?(d=this.hc[p],d.coord=this.jt(g.index),d.label=this.Fc(g),d.weight=g.weight):(d={needAlignCoordinate:!1,coord:this.jt(g.index),label:this.Fc(g),weight:g.weight},this.hc.push(d)),this.oc>n/2&&!a?d.needAlignCoordinate=!1:d.needAlignCoordinate=u&&g.index<=c||f&&g.index>=h,p++}return this.hc.length=p,this.sc=this.hc,this.hc}Wc(){let t;this.Xu=!0,this.Ms(this.yn.barSpacing),t=this.yn.rightOffsetPixels!==void 0?this.yn.rightOffsetPixels/this.ml():this.yn.rightOffset,this.gs(t)}Hc(t){this.Xu=!0,this.qu=t,this.Rc(),this.mc()}Uc(t,n){const s=this.Bc(t),i=this.ml(),r=i+n*(i/10);this.Ms(r),this.yn.rightBarStaysOnScroll||this.gs(this.Oc()+(s-this.Bc(t)))}u_(t){this.Po&&this.v_(),this.yo===null&&this.nc===null&&(this.Zi()||(this.yo=t,this.$c()))}c_(t){if(this.nc===null)return;const n=Ls(this.k_-t,0,this.k_),s=Ls(this.k_-K(this.yo),0,this.k_);n!==0&&s!==0&&this.Ms(this.nc.ml*n/s)}d_(){this.yo!==null&&(this.yo=null,this.jc())}f_(t){this.Po===null&&this.nc===null&&(this.Zi()||(this.Po=t,this.$c()))}p_(t){if(this.Po===null)return;const n=(this.Po-t)/this.ml();this.lc=K(this.nc).Oc+n,this.Xu=!0,this.Rc()}v_(){this.Po!==null&&(this.Po=null,this.jc())}qc(){this.Yc(this.yn.rightOffset)}Yc(t,n=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(n)||n<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.lc,i=performance.now();this.sn.ps({Kc:r=>(r-i)/n>=1,Gc:r=>{const o=(r-i)/n;return o>=1?t:s+(t-s)*o}})}Pt(t,n){this.Xu=!0,this.Yu=t,this.Ku.Au(t,n),this.Rc()}Zc(){return this.Ju}Xc(){return this.Qu}Jc(){return this.tc}Dc(){return this.qu||0}Qc(t,n){const s=t.Iu(),i=n&&this.yn.rightOffsetPixels||0;this.zc((this.k_-i)/s),this.lc=t.bi()-this.Dc(),n&&(this.lc=i?i/this.ml():this.yn.rightOffset),this.Rc(),this.Xu=!0,this.sn.Lc(),this.sn.mr()}td(){const t=this.yc(),n=this.Pc();if(t===null||n===null)return;const s=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Qc(new Si(t,n+s),!0)}nd(t){const n=new Si(t.from,t.to);this.Qc(n)}rn(t){return this.Do.timeFormatter!==void 0?this.Do.timeFormatter(t.originalTime):this.Pu.formatHorzItem(t.time)}dc(){if(!this.yn.ignoreWhitespaceIndices)return;this.ec.clear();const t=this.sn.Jn();for(const n of t)for(const s of n.fl())this.ec.set(s,!0);this.rc++}sd(){return this.ac}Sl(){const t=1/(window.devicePixelRatio||1),n=this.yn.minBarSpacing;if(n>=t)return[1];const s=[1];let i=2;for(;i<=512;)n<t/i&&s.push(i),i*=2;return s}Nc(){const t=this.sn.N().handleScroll,n=this.sn.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||n.axisDoubleClickReset.time||n.axisPressedMouseMove.time||n.mouseWheel||n.pinch)}yc(){return this.Yu.length===0?null:0}Pc(){return this.Yu.length===0?null:this.Yu.length-1}ed(t){return(this.k_-1-t)/this.oc}Bc(t){const n=this.ed(t),s=this.Dc()+this.lc-n;return Math.round(1e6*s)/1e6}zc(t){const n=this.oc;this.oc=t,this.Tc(),n!==this.oc&&(this.Xu=!0,this.rd(),this.cc())}bc(){if(!this.Xu)return;if(this.Xu=!1,this.Zi())return void this.hd(zs.ju());const t=this.Dc(),n=this.k_/this.oc,s=this.lc+t,i=new Si(s-n+1,s);this.hd(new zs(i))}Tc(){const t=Ls(this.oc,this.ad(),this.ld());this.oc!==t&&(this.oc=t,this.Xu=!0)}ld(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.k_}ad(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&this.Yu.length!==0?this.k_/this.Yu.length:this.yn.minBarSpacing}cc(){if(!this.yn.enableConflation)return void(this.ac=1);const t=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.oc>=t)return void(this.ac=1);const n=t/this.oc,s=Math.pow(2,Math.floor(Math.log2(n)));this.ac=Math.min(s,512)}Rc(){const t=this.od();t!==null&&this.lc<t&&(this.lc=t,this.Xu=!0);const n=this._d();this.lc>n&&(this.lc=n,this.Xu=!0)}od(){const t=this.yc(),n=this.qu;return t===null||n===null?null:t-n-1+(this.yn.fixLeftEdge?this.k_/this.oc:Math.min(2,this.Yu.length))}_d(){return this.yn.fixRightEdge?0:this.k_/this.oc-Math.min(2,this.Yu.length)}$c(){this.nc={ml:this.ml(),Oc:this.Oc()}}jc(){this.nc=null}Fc(t){let n=this.Gu.get(t.weight);return n===void 0&&(n=new Mx(s=>this.ud(s),this.Pu),this.Gu.set(t.weight,n)),n.ku(t)}ud(t){return this.Pu.formatTickmark(t,this.Do)}hd(t){const n=this.Zu;this.Zu=t,Kh(n.Uu(),this.Zu.Uu())||this.Ju.p(),Kh(n.$u(),this.Zu.$u())||this.Qu.p(),this.rd()}rd(){this.sc=null}vc(){this.rd(),this.Gu.clear()}uc(){this.Pu.updateFormatter(this.Do)}mc(){if(!this.yn.fixLeftEdge)return;const t=this.yc();if(t===null)return;const n=this.Ee();if(n===null)return;const s=n.Na()-t;if(s<0){const i=this.lc-s-1;this.gs(i)}this.Tc()}wc(){this.Rc(),this.Tc()}Ec(t){return!this.yn.ignoreWhitespaceIndices||this.ec.get(t)||!1}Ac(t){const n=function*(i){const r=Math.round(i),o=r<i;let l=1;for(;;)o?(yield r+l,yield r-l):(yield r-l,yield r+l),l++}(t),s=this.Pc();for(;s;){const i=n.next().value;if(this.ec.get(i))return i;if(i<0||i>s)break}return t}_c(t){if(t.rightOffsetPixels!==void 0){const n=t.rightOffsetPixels/(t.barSpacing||this.oc);this.sn.gs(n)}}}var Zh,tu,eu,nu,su;(function(e){e[e.OnTouchEnd=0]="OnTouchEnd",e[e.OnNextTap=1]="OnNextTap"})(Zh||(Zh={}));class Rx{constructor(t,n,s){this.dd=[],this.fd=[],this.pd=null,this.k_=0,this.vd=null,this.md=new Zt,this.wd=new Zt,this.Md=null,this.gd=t,this.yn=n,this.Pu=s,this.Io=new kv(this.yn.layout.colorParsers),this.bd=new Cv(this),this.ia=new Ax(this,n.timeScale,this.yn.localization,s),this.Ct=new Lv(this,n.crosshair),this.Sd=new px(n.crosshair),n.addDefaultPane&&(this.xd(0),this.dd[0].W_(2)),this.Cd=this.yd(0),this.Pd=this.yd(1)}ka(){this.kd(fe.ys())}mr(){this.kd(fe.Cs())}Ya(){this.kd(new fe(1))}Ta(t){const n=this.Td(t);this.kd(n)}cu(){return this.vd}Rd(t){var s,i,r,o,l,c,h,a,u;if(((s=this.vd)==null?void 0:s.uu)===(t==null?void 0:t.uu)&&((r=(i=this.vd)==null?void 0:i.bu)==null?void 0:r.te)===((o=t==null?void 0:t.bu)==null?void 0:o.te)&&((c=(l=this.vd)==null?void 0:l.bu)==null?void 0:c.ie)===((h=t==null?void 0:t.bu)==null?void 0:h.ie)&&((a=this.vd)==null?void 0:a.gu)===(t==null?void 0:t.gu)&&((u=this.vd)==null?void 0:u.ee)===(t==null?void 0:t.ee))return;const n=this.vd;this.vd=t,n!==null&&this.Ta(n.uu),t!==null&&t.uu!==(n==null?void 0:n.uu)&&this.Ta(t.uu)}N(){return this.yn}vr(t){$e(this.yn,t),this.dd.forEach(n=>n.z_(t)),t.timeScale!==void 0&&this.ia.vr(t.timeScale),t.localization!==void 0&&this.ia.fc(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.md.p(),this.Cd=this.yd(0),this.Pd=this.yd(1),this.ka()}Dd(t,n,s=0){const i=this.dd[s];if(i===void 0)return;if(t==="left")return $e(this.yn,{leftPriceScale:n}),i.z_({leftPriceScale:n}),this.md.p(),void this.ka();if(t==="right")return $e(this.yn,{rightPriceScale:n}),i.z_({rightPriceScale:n}),this.md.p(),void this.ka();const r=this.Id(t,s);r!==null&&(r.Ft.vr(n),this.md.p())}Id(t,n){const s=this.dd[n];if(s===void 0)return null;const i=s.O_(t);return i!==null?{Kn:s,Ft:i}:null}Et(){return this.ia}Gn(){return this.dd}Vd(){return this.Ct}Bd(){return this.wd}Ed(t,n){t.$o(n),this.Lc()}H_(t){this.k_=t,this.ia.H_(this.k_),this.dd.forEach(n=>n.H_(t)),this.Lc()}Ad(t){this.dd.length!==1&&(pe(t>=0&&t<this.dd.length,"Invalid pane index"),this.dd.splice(t,1),this.ka())}Ld(t,n){if(this.dd.length<2)return;pe(t>=0&&t<this.dd.length,"Invalid pane index");const s=this.dd[t],i=this.dd.reduce((u,f)=>u+f.F_(),0),r=this.dd.reduce((u,f)=>u+f.$t(),0),o=r-30*(this.dd.length-1);n=Math.min(o,Math.max(30,n));const l=i/r,c=s.$t();s.W_(n*l);let h=n-c,a=this.dd.length-1;for(const u of this.dd)if(u!==s){const f=Math.min(o,Math.max(30,u.$t()-h/a));h-=u.$t()-f,a-=1;const p=f*l;u.W_(p)}this.ka()}zd(t,n){pe(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index");const s=this.dd[t],i=this.dd[n];this.dd[t]=i,this.dd[n]=s,this.ka()}Od(t,n){if(pe(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index"),t===n)return;const[s]=this.dd.splice(t,1);this.dd.splice(n,0,s),this.ka()}Q_(t,n,s){t.Q_(n,s)}tu(t,n,s){t.tu(n,s),this.Ra(),this.kd(this.Nd(t,2))}iu(t,n){t.iu(n),this.kd(this.Nd(t,2))}nu(t,n,s){n.zo()||t.nu(n,s)}su(t,n,s){n.zo()||(t.su(n,s),this.Ra(),this.kd(this.Nd(t,2)))}eu(t,n){n.zo()||(t.eu(n),this.kd(this.Nd(t,2)))}au(t,n){t.au(n),this.kd(this.Nd(t,2))}Fd(t){this.ia.u_(t)}Wd(t,n){const s=this.Et();if(s.Zi()||n===0)return;const i=s.nn();t=Math.max(1,Math.min(t,i)),s.Uc(t,n),this.Lc()}Hd(t){this.Ud(0),this.$d(t),this.jd()}qd(t){this.ia.c_(t),this.Lc()}Yd(){this.ia.d_(),this.mr()}Ud(t){this.ia.f_(t)}$d(t){this.ia.p_(t),this.Lc()}jd(){this.ia.v_(),this.mr()}Jn(){return this.fd}Wn(){return this.pd===null&&(this.pd=this.fd.filter(t=>t.It())),this.pd}Pa(){this.pd=null}Kd(t,n,s,i,r){this.Ct.In(t,n);let o=NaN,l=this.ia.Vc(t,!0);const c=this.ia.Ee();c!==null&&(l=Math.min(Math.max(c.Na(),l),c.bi())),l=this.Ct.Fn(l);const h=i.kn(),a=h.Lt();if(a!==null&&(o=h.Tn(n,a)),o=this.Sd.Pl(o,l,i),this.Ct.An(l,o,i),this.Ya(),!r){const u=Kf(i,t,n);this.Rd(u&&{uu:u.uu,bu:u.bu,gu:u.gu||null,ee:u.ee}),this.wd.p(this.Ct.Bt(),{x:t,y:n},s)}}Gd(t,n,s){const i=s.kn(),r=i.Lt(),o=i.Nt(t,K(r)),l=this.ia.Mc(n,!0),c=this.ia.jt(K(l));this.Kd(c,o,null,s,!0)}Zd(t){this.Vd().zn(),this.Ya(),t||this.wd.p(null,null,null)}Ra(){const t=this.Ct.Kn();if(t!==null){const n=this.Ct.Bn(),s=this.Ct.En();this.Kd(n,s,null,t)}this.Ct.Nn()}Xd(t,n,s){const i=this.ia.Rn(0);n!==void 0&&s!==void 0&&this.ia.Pt(n,s);const r=this.ia.Rn(0),o=this.ia.Dc(),l=this.ia.Ee();if(l!==null&&i!==null&&r!==null){const c=l.ze(o),h=this.Pu.key(i)>this.Pu.key(r),a=t!==null&&t>o&&!h,u=this.ia.N().allowShiftVisibleRangeOnWhitespaceReplacement,f=c&&(s!==void 0||u)&&this.ia.N().shiftVisibleRangeOnNewBar;if(a&&!f){const p=t-o;this.ia.gs(this.ia.Oc()-p)}}this.ia.Hc(t)}Ba(t){t!==null&&t.ou()}Ks(t){if(function(s){return s instanceof va}(t))return t;const n=this.dd.find(s=>s.Dt().includes(t));return n===void 0?null:n}Lc(){this.dd.forEach(t=>t.ou()),this.Ra()}m(){this.dd.forEach(t=>t.m()),this.dd.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Jd(){return this.bd}Js(){return this.bd.N()}N_(){return this.md}Qd(t,n){const s=this.xd(n);this.tf(t,s),this.fd.push(t),this.Pa(),this.fd.length===1?this.ka():this.mr()}if(t){const n=this.Ks(t),s=this.fd.indexOf(t);pe(s!==-1,"Series not found");const i=K(n);this.fd.splice(s,1),i.l_(t),t.m&&t.m(),this.Pa(),this.ia.dc(),this.nf(i)}ya(t,n){const s=K(this.Ks(t));s.l_(t,!0),s.h_(t,n,!0)}td(){const t=fe.Cs();t.us(),this.kd(t)}sf(t){const n=fe.Cs();n.fs(t),this.kd(n)}ws(){const t=fe.Cs();t.ws(),this.kd(t)}Ms(t){const n=fe.Cs();n.Ms(t),this.kd(n)}gs(t){const n=fe.Cs();n.gs(t),this.kd(n)}ps(t){const n=fe.Cs();n.ps(t),this.kd(n)}cs(){const t=fe.Cs();t.cs(),this.kd(t)}ef(){const t=this.yn.defaultVisiblePriceScaleId,n=this.yn.leftPriceScale.visible;return n!==this.yn.rightPriceScale.visible?n?"left":"right":t}rf(t,n){if(pe(n>=0,"Index should be greater or equal to 0"),n===this.hf(t))return;const s=K(this.Ks(t));s.l_(t);const i=this.xd(n);this.tf(t,i);let r=!1;s.kl().length===0&&(r=this.nf(s)),r||this.ka()}af(){return this.Pd}$(){return this.Cd}Ut(t){const n=this.Pd,s=this.Cd;if(n===s)return n;if(t=Math.max(0,Math.min(100,Math.round(100*t))),this.Md===null||this.Md.ah!==s||this.Md.oh!==n)this.Md={ah:s,oh:n,lf:new Map};else{const r=this.Md.lf.get(t);if(r!==void 0)return r}const i=this.Io.tt(s,n,t/100);return this.Md.lf.set(t,i),i}_f(t){return this.dd.indexOf(t)}Xi(){return this.Io}uf(){return this.cf()}cf(t){const n=new va(this.ia,this);this.dd.push(n);const s=t??this.dd.length-1,i=fe.ys();return i.es(s,{rs:0,hs:!0}),this.kd(i),n}xd(t){return pe(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.dd.length,t))<this.dd.length?this.dd[t]:this.cf(t)}hf(t){return this.dd.findIndex(n=>n.Y_().includes(t))}Nd(t,n){const s=new fe(n);if(t!==null){const i=this.dd.indexOf(t);s.es(i,{rs:n})}return s}Td(t,n){return n===void 0&&(n=2),this.Nd(this.Ks(t),n)}kd(t){this.gd&&this.gd(t),this.dd.forEach(n=>n.wu().wr().Pt())}tf(t,n){const s=t.N().priceScaleId,i=s!==void 0?s:this.ef();n.h_(t,i),Qr(i)||t.vr(t.N())}yd(t){const n=this.yn.layout;return n.background.type==="gradient"?t===0?n.background.topColor:n.background.bottomColor:n.background.color}nf(t){return!t.q_()&&t.kl().length===0&&this.dd.length>1&&(this.dd.splice(this._f(t),1),this.ka(),!0)}}function Zf(e){if(e>=1)return 0;let t=0;for(;t<8;t++){const n=Math.round(e);if(Math.abs(n-e)<1e-8)return t;e*=10}return t}function wa(e){return!js(e)&&!Bi(e)}function tm(e){return js(e)}(function(e){e[e.Disabled=0]="Disabled",e[e.Continuous=1]="Continuous",e[e.OnDataUpdate=2]="OnDataUpdate"})(tu||(tu={})),function(e){e[e.LastBar=0]="LastBar",e[e.LastVisible=1]="LastVisible"}(eu||(eu={})),function(e){e.Solid="solid",e.VerticalGradient="gradient"}(nu||(nu={})),function(e){e[e.Year=0]="Year",e[e.Month=1]="Month",e[e.DayOfMonth=2]="DayOfMonth",e[e.Time=3]="Time",e[e.TimeWithSeconds=4]="TimeWithSeconds"}(su||(su={}));const iu=e=>e.getUTCFullYear();function Px(e,t,n){return t.replace(/yyyy/g,(s=>ln(iu(s),4))(e)).replace(/yy/g,(s=>ln(iu(s)%100,2))(e)).replace(/MMMM/g,((s,i)=>new Date(s.getUTCFullYear(),s.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(e,n)).replace(/MMM/g,((s,i)=>new Date(s.getUTCFullYear(),s.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(e,n)).replace(/MM/g,(s=>ln((i=>i.getUTCMonth()+1)(s),2))(e)).replace(/dd/g,(s=>ln((i=>i.getUTCDate())(s),2))(e))}class em{constructor(t="yyyy-MM-dd",n="default"){this.df=t,this.ff=n}ku(t){return Px(t,this.df,this.ff)}}class _x{constructor(t){this.pf=t||"%h:%m:%s"}ku(t){return this.pf.replace("%h",ln(t.getUTCHours(),2)).replace("%m",ln(t.getUTCMinutes(),2)).replace("%s",ln(t.getUTCSeconds(),2))}}const $x={vf:"yyyy-MM-dd",mf:"%h:%m:%s",wf:" ",Mf:"default"};class Nx{constructor(t={}){const n={...$x,...t};this.gf=new em(n.vf,n.Mf),this.bf=new _x(n.mf),this.Sf=n.wf}ku(t){return`${this.gf.ku(t)}${this.Sf}${this.bf.ku(t)}`}}function dr(e){return 60*e*60*1e3}function Do(e){return 60*e*1e3}const fr=[{xf:(ru=1,1e3*ru),Cf:10},{xf:Do(1),Cf:20},{xf:Do(5),Cf:21},{xf:Do(30),Cf:22},{xf:dr(1),Cf:30},{xf:dr(3),Cf:31},{xf:dr(6),Cf:32},{xf:dr(12),Cf:33}];var ru;function ou(e,t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;for(let n=fr.length-1;n>=0;--n)if(Math.floor(t.getTime()/fr[n].xf)!==Math.floor(e.getTime()/fr[n].xf))return fr[n].Cf;return 0}function Lo(e){let t=e;if(Bi(e)&&(t=wl(e)),!wa(t))throw new Error("time must be of type BusinessDay");const n=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{yf:Math.round(n.getTime()/1e3),Pf:t}}function au(e){if(!tm(e))throw new Error("time must be of type isUTCTimestamp");return{yf:e}}function wl(e){const t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid date string=${e}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function lu(e){Bi(e.time)&&(e.time=wl(e.time))}class cu{options(){return this.yn}setOptions(t){this.yn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(n){n.forEach(lu)}(t):lu(t)}createConverterToInternalObj(t){return K(function(n){return n.length===0?null:wa(n[0].time)||Bi(n[0].time)?Lo:au}(t))}key(t){return typeof t=="object"&&"yf"in t?t.yf:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const n=t;return n.Pf===void 0?new Date(1e3*n.yf).getTime():new Date(Date.UTC(n.Pf.year,n.Pf.month-1,n.Pf.day)).getTime()}convertHorzItemToInternal(t){return tm(n=t)?au(n):wa(n)?Lo(n):Lo(wl(n));var n}updateFormatter(t){if(!this.yn)return;const n=t.dateFormat;this.yn.timeScale.timeVisible?this.kf=new Nx({vf:n,mf:this.yn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",wf:" ",Mf:t.locale}):this.kf=new em(n,t.locale)}formatHorzItem(t){const n=t;return this.kf.ku(new Date(1e3*n.yf))}formatTickmark(t,n){const s=function(r,o,l){switch(r){case 0:case 10:return o?l?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return o?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),i=this.yn.timeScale;if(i.tickMarkFormatter!==void 0){const r=i.tickMarkFormatter(t.originalTime,s,n.locale);if(r!==null)return r}return function(r,o,l){const c={};switch(o){case 0:c.year="numeric";break;case 1:c.month="short";break;case 2:c.day="numeric";break;case 3:c.hour12=!1,c.hour="2-digit",c.minute="2-digit";break;case 4:c.hour12=!1,c.hour="2-digit",c.minute="2-digit",c.second="2-digit"}const h=r.Pf===void 0?new Date(1e3*r.yf):new Date(Date.UTC(r.Pf.year,r.Pf.month-1,r.Pf.day));return new Date(h.getUTCFullYear(),h.getUTCMonth(),h.getUTCDate(),h.getUTCHours(),h.getUTCMinutes(),h.getUTCSeconds(),h.getUTCMilliseconds()).toLocaleString(l,c)}(t.time,s,n.locale)}maxTickMarkWeight(t){let n=t.reduce(Tx,t[0]).weight;return n>30&&n<50&&(n=30),n}fillWeightsForPoints(t,n){(function(s,i=0){if(s.length===0)return;let r=i===0?null:s[i-1].time.yf,o=r!==null?new Date(1e3*r):null,l=0;for(let c=i;c<s.length;++c){const h=s[c],a=new Date(1e3*h.time.yf);o!==null&&(h.timeWeight=ou(a,o)),l+=h.time.yf-(r||h.time.yf),r=h.time.yf,o=a}if(i===0&&s.length>1){const c=Math.ceil(l/(s.length-1)),h=new Date(1e3*(s[0].time.yf-c));s[0].timeWeight=ou(new Date(1e3*s[0].time.yf),h)}})(t,n)}static Tf(t){return $e({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Vs=typeof window<"u";function hu(){return!!Vs&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function zo(){return!!Vs&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function Ix(e,t){switch(e){case"custom":return t!==void 0?"custom-object":"series";case"price-line":return"custom-price-line";case"marker":return"series-marker";case"primitive":return"primitive";default:return"series"}}function Sa(e){return e+e%2}function Dx(e){Vs&&window.chrome!==void 0&&e.addEventListener("mousedown",t=>{if(t.button===1)return t.preventDefault(),!1})}class Zr{constructor(t,n,s){this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Af=null,this.Lf=!1,this.zf=null,this.Of=null,this.Nf=!1,this.Ff=!1,this.Wf=!1,this.Hf=null,this.Uf=null,this.$f=null,this.jf=null,this.qf=null,this.Yf=null,this.Kf=null,this.Gf=0,this.Zf=!1,this.Xf=!1,this.Jf=!1,this.Qf=0,this.tp=null,this.ip=!zo(),this.np=i=>{this.sp(i)},this.ep=i=>{if(this.rp(i)){const r=this.hp(i);if(++this.Vf,this.Bf&&this.Vf>1){const{ap:o}=this.lp(Xe(i),this.Ef);o<30&&!this.Wf&&this.op(r,this.up._p),this.cp()}}else{const r=this.hp(i);if(++this.Rf,this.Df&&this.Rf>1){const{ap:o}=this.lp(Xe(i),this.If);o<5&&!this.Ff&&this.dp(r,this.up.fp),this.pp()}}},this.vp=t,this.up=n,this.yn=s,this.mp()}m(){this.Hf!==null&&(this.Hf(),this.Hf=null),this.Uf!==null&&(this.Uf(),this.Uf=null),this.jf!==null&&(this.jf(),this.jf=null),this.qf!==null&&(this.qf(),this.qf=null),this.Yf!==null&&(this.Yf(),this.Yf=null),this.$f!==null&&(this.$f(),this.$f=null),this.wp(),this.pp()}Mp(t){this.jf&&this.jf();const n=this.gp.bind(this);if(this.jf=()=>{this.vp.removeEventListener("mousemove",n)},this.vp.addEventListener("mousemove",n),this.rp(t))return;const s=this.hp(t);this.dp(s,this.up.bp),this.ip=!0}pp(){this.Df!==null&&clearTimeout(this.Df),this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}cp(){this.Bf!==null&&clearTimeout(this.Bf),this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}gp(t){if(this.Jf||this.Of!==null||this.rp(t))return;const n=this.hp(t);this.dp(n,this.up.Sp),this.ip=!0}xp(t){const n=Fo(t.changedTouches,K(this.tp));if(n===null||(this.Qf=mr(t),this.Kf!==null)||this.Xf)return;this.Zf=!0;const s=this.lp(Xe(n),K(this.Of)),{Cp:i,yp:r,ap:o}=s;if(this.Nf||!(o<5)){if(!this.Nf){const l=.5*i,c=r>=l&&!this.yn.Pp(),h=l>r&&!this.yn.kp();c||h||(this.Xf=!0),this.Nf=!0,this.Wf=!0,this.wp(),this.cp()}if(!this.Xf){const l=this.hp(t,n);this.op(l,this.up.Tp),Ms(t)}}}Rp(t){if(t.button!==0)return;const n=this.lp(Xe(t),K(this.zf)),{ap:s}=n;if(s>=5&&(this.Ff=!0,this.pp()),this.Ff){const i=this.hp(t);this.dp(i,this.up.Dp)}}lp(t,n){const s=Math.abs(n._t-t._t),i=Math.abs(n.ut-t.ut);return{Cp:s,yp:i,ap:s+i}}Ip(t){let n=Fo(t.changedTouches,K(this.tp));if(n===null&&t.touches.length===0&&(n=t.changedTouches[0]),n===null)return;this.tp=null,this.Qf=mr(t),this.wp(),this.Of=null,this.Yf&&(this.Yf(),this.Yf=null);const s=this.hp(t,n);if(this.op(s,this.up.Vp),++this.Vf,this.Bf&&this.Vf>1){const{ap:i}=this.lp(Xe(n),this.Ef);i<30&&!this.Wf&&this.op(s,this.up._p),this.cp()}else this.Wf||(this.op(s,this.up.Bp),this.up.Bp&&Ms(t));this.Vf===0&&Ms(t),t.touches.length===0&&this.Lf&&(this.Lf=!1,Ms(t))}sp(t){if(t.button!==0)return;const n=this.hp(t);if(this.zf=null,this.Jf=!1,this.qf&&(this.qf(),this.qf=null),hu()&&this.vp.ownerDocument.documentElement.removeEventListener("mouseleave",this.np),!this.rp(t))if(this.dp(n,this.up.Ep),++this.Rf,this.Df&&this.Rf>1){const{ap:s}=this.lp(Xe(t),this.If);s<5&&!this.Ff&&this.dp(n,this.up.fp),this.pp()}else this.Ff||this.dp(n,this.up.Ap)}wp(){this.Af!==null&&(clearTimeout(this.Af),this.Af=null)}Lp(t){if(this.tp!==null)return;const n=t.changedTouches[0];this.tp=n.identifier,this.Qf=mr(t);const s=this.vp.ownerDocument.documentElement;this.Wf=!1,this.Nf=!1,this.Xf=!1,this.Of=Xe(n),this.Yf&&(this.Yf(),this.Yf=null);{const r=this.xp.bind(this),o=this.Ip.bind(this);this.Yf=()=>{s.removeEventListener("touchmove",r),s.removeEventListener("touchend",o)},s.addEventListener("touchmove",r,{passive:!1}),s.addEventListener("touchend",o,{passive:!1}),this.wp(),this.Af=setTimeout(this.zp.bind(this,t),240)}const i=this.hp(t,n);this.op(i,this.up.Op),this.Bf||(this.Vf=0,this.Bf=setTimeout(this.cp.bind(this),500),this.Ef=Xe(n))}Np(t){if(t.button!==0)return;const n=this.vp.ownerDocument.documentElement;hu()&&n.addEventListener("mouseleave",this.np),this.Ff=!1,this.zf=Xe(t),this.qf&&(this.qf(),this.qf=null);{const i=this.Rp.bind(this),r=this.sp.bind(this);this.qf=()=>{n.removeEventListener("mousemove",i),n.removeEventListener("mouseup",r)},n.addEventListener("mousemove",i),n.addEventListener("mouseup",r)}if(this.Jf=!0,this.rp(t))return;const s=this.hp(t);this.dp(s,this.up.Fp),this.Df||(this.Rf=0,this.Df=setTimeout(this.pp.bind(this),500),this.If=Xe(t))}mp(){this.vp.addEventListener("mouseenter",this.Mp.bind(this)),this.vp.addEventListener("touchcancel",this.wp.bind(this));{const t=this.vp.ownerDocument,n=s=>{this.up.Wp&&(s.composed&&this.vp.contains(s.composedPath()[0])||s.target&&this.vp.contains(s.target)||this.up.Wp())};this.Uf=()=>{t.removeEventListener("touchstart",n)},this.Hf=()=>{t.removeEventListener("mousedown",n)},t.addEventListener("mousedown",n),t.addEventListener("touchstart",n,{passive:!0})}zo()&&(this.$f=()=>{this.vp.removeEventListener("dblclick",this.ep)},this.vp.addEventListener("dblclick",this.ep)),this.vp.addEventListener("mouseleave",this.Hp.bind(this)),this.vp.addEventListener("touchstart",this.Lp.bind(this),{passive:!0}),Dx(this.vp),this.vp.addEventListener("mousedown",this.Np.bind(this)),this.Up(),this.vp.addEventListener("touchmove",()=>{},{passive:!1})}Up(){this.up.$p===void 0&&this.up.jp===void 0&&this.up.qp===void 0||(this.vp.addEventListener("touchstart",t=>this.Yp(t.touches),{passive:!0}),this.vp.addEventListener("touchmove",t=>{if(t.touches.length===2&&this.Kf!==null&&this.up.jp!==void 0){const n=uu(t.touches[0],t.touches[1])/this.Gf;this.up.jp(this.Kf,n),Ms(t)}},{passive:!1}),this.vp.addEventListener("touchend",t=>{this.Yp(t.touches)}))}Yp(t){t.length===1&&(this.Zf=!1),t.length!==2||this.Zf||this.Lf?this.Kp():this.Gp(t)}Gp(t){const n=this.vp.getBoundingClientRect()||{left:0,top:0};this.Kf={_t:(t[0].clientX-n.left+(t[1].clientX-n.left))/2,ut:(t[0].clientY-n.top+(t[1].clientY-n.top))/2},this.Gf=uu(t[0],t[1]),this.up.$p!==void 0&&this.up.$p(),this.wp()}Kp(){this.Kf!==null&&(this.Kf=null,this.up.qp!==void 0&&this.up.qp())}Hp(t){if(this.jf&&this.jf(),this.rp(t)||!this.ip)return;const n=this.hp(t);this.dp(n,this.up.Zp),this.ip=!zo()}zp(t){const n=Fo(t.touches,K(this.tp));if(n===null)return;const s=this.hp(t,n);this.op(s,this.up.Xp),this.Wf=!0,this.Lf=!0}rp(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents!==void 0?t.sourceCapabilities.firesTouchEvents:mr(t)<this.Qf+500}op(t,n){n&&n.call(this.up,t)}dp(t,n){n&&n.call(this.up,t)}hp(t,n){const s=n||t,i=this.vp.getBoundingClientRect()||{left:0,top:0};return{clientX:s.clientX,clientY:s.clientY,pageX:s.pageX,pageY:s.pageY,screenX:s.screenX,screenY:s.screenY,localX:s.clientX-i.left,localY:s.clientY-i.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Jp:!t.type.startsWith("mouse")&&t.type!=="contextmenu"&&t.type!=="click",Qp:t.type,tv:s.target,xu:t.view,iv:()=>{t.type!=="touchstart"&&Ms(t)}}}}function uu(e,t){const n=e.clientX-t.clientX,s=e.clientY-t.clientY;return Math.sqrt(n*n+s*s)}function Ms(e){e.cancelable&&e.preventDefault()}function Xe(e){return{_t:e.pageX,ut:e.pageY}}function mr(e){return e.timeStamp||performance.now()}function Fo(e,t){for(let n=0;n<e.length;++n)if(e[n].identifier===t)return e[n];return null}class Lx{constructor(t,n,s){this.nv=null,this.sv=null,this.ev=!0,this.rv=null,this.hv=t,this.av=t.lv()[n],this.ov=t.lv()[s],this._v=document.createElement("tr"),this._v.style.height="1px",this.uv=document.createElement("td"),this.uv.style.position="relative",this.uv.style.padding="0",this.uv.style.margin="0",this.uv.setAttribute("colspan","3"),this.cv(),this._v.appendChild(this.uv),this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv=null,this.sv=null)}m(){this.sv!==null&&this.sv.m()}fv(){return this._v}pv(){return Nt({width:this.av.pv().width,height:1})}vv(){return Nt({width:this.av.vv().width,height:1*window.devicePixelRatio})}mv(t,n,s){const i=this.vv();t.fillStyle=this.hv.N().layout.panes.separatorColor,t.fillRect(n,s,i.width,i.height)}Pt(){this.cv(),this.hv.N().layout.panes.enableResize!==this.ev&&(this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv!==null&&(this.uv.removeChild(this.nv.wv),this.uv.removeChild(this.nv.Mv),this.nv=null),this.sv!==null&&(this.sv.m(),this.sv=null)))}dv(){const t=document.createElement("div"),n=t.style;n.position="fixed",n.display="none",n.zIndex="49",n.top="0",n.left="0",n.width="100%",n.height="100%",n.cursor="row-resize",this.uv.appendChild(t);const s=document.createElement("div"),i=s.style;i.position="absolute",i.zIndex="50",i.top="-4px",i.height="9px",i.width="100%",i.backgroundColor="",i.cursor="row-resize",this.uv.appendChild(s);const r={bp:this.gv.bind(this),Zp:this.bv.bind(this),Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this)};this.sv=new Zr(s,r,{Pp:()=>!1,kp:()=>!0}),this.nv={Mv:s,wv:t}}cv(){this.uv.style.background=this.hv.N().layout.panes.separatorColor}gv(t){this.nv!==null&&(this.nv.Mv.style.backgroundColor=this.hv.N().layout.panes.separatorHoverColor)}bv(t){this.nv!==null&&this.rv===null&&(this.nv.Mv.style.backgroundColor="")}Sv(t){if(this.nv===null)return;const n=this.av.yv().F_()+this.ov.yv().F_(),s=n/(this.av.pv().height+this.ov.pv().height),i=30*s;n<=2*i||(this.rv={Pv:t.pageY,kv:this.av.yv().F_(),Tv:n-i,Rv:n,Dv:s,Iv:i},this.nv.wv.style.display="block")}xv(t){const n=this.rv;if(n===null)return;const s=(t.pageY-n.Pv)*n.Dv,i=Ls(n.kv+s,n.Iv,n.Tv);this.av.yv().W_(i),this.ov.yv().W_(n.Rv-i),this.hv.Qt().ka()}Cv(t){this.rv!==null&&this.nv!==null&&(this.rv=null,this.nv.wv.style.display="none")}}function Bo(e,t){return e.Vv-t.Vv}function Wo(e,t,n){const s=(e.Vv-t.Vv)/(e.wt-t.wt);return Math.sign(s)*Math.min(Math.abs(s),n)}class zx{constructor(t,n,s,i){this.Bv=null,this.Ev=null,this.Av=null,this.Lv=null,this.zv=null,this.Ov=0,this.Nv=0,this.Fv=t,this.Wv=n,this.Hv=s,this.Ps=i}Uv(t,n){if(this.Bv!==null){if(this.Bv.wt===n)return void(this.Bv.Vv=t);if(Math.abs(this.Bv.Vv-t)<this.Ps)return}this.Lv=this.Av,this.Av=this.Ev,this.Ev=this.Bv,this.Bv={wt:n,Vv:t}}me(t,n){if(this.Bv===null||this.Ev===null||n-this.Bv.wt>50)return;let s=0;const i=Wo(this.Bv,this.Ev,this.Wv),r=Bo(this.Bv,this.Ev),o=[i],l=[r];if(s+=r,this.Av!==null){const h=Wo(this.Ev,this.Av,this.Wv);if(Math.sign(h)===Math.sign(i)){const a=Bo(this.Ev,this.Av);if(o.push(h),l.push(a),s+=a,this.Lv!==null){const u=Wo(this.Av,this.Lv,this.Wv);if(Math.sign(u)===Math.sign(i)){const f=Bo(this.Av,this.Lv);o.push(u),l.push(f),s+=f}}}}let c=0;for(let h=0;h<o.length;++h)c+=l[h]/s*o[h];Math.abs(c)<this.Fv||(this.zv={Vv:t,wt:n},this.Nv=c,this.Ov=function(h,a){const u=Math.log(a);return Math.log(1*u/-h)/u}(Math.abs(c),this.Hv))}Gc(t){const n=K(this.zv),s=t-n.wt;return n.Vv+this.Nv*(Math.pow(this.Hv,s)-1)/Math.log(this.Hv)}Kc(t){return this.zv===null||this.$v(t)===this.Ov}$v(t){const n=t-K(this.zv).wt;return Math.min(n,this.Ov)}}class Fx{constructor(t,n){this.jv=void 0,this.qv=void 0,this.Yv=void 0,this.vn=!1,this.Kv=t,this.Gv=n,this.Zv()}Pt(){this.Zv()}Xv(){this.jv&&this.Kv.removeChild(this.jv),this.qv&&this.Kv.removeChild(this.qv),this.jv=void 0,this.qv=void 0}Jv(){return this.vn!==this.Qv()||this.Yv!==this.tm()}tm(){return this.Gv.Qt().Xi().J(this.Gv.N().layout.textColor)>160?"dark":"light"}Qv(){return this.Gv.N().layout.attributionLogo}im(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Zv(){this.Jv()&&(this.Xv(),this.vn=this.Qv(),this.vn&&(this.Yv=this.tm(),this.qv=document.createElement("style"),this.qv.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.jv=document.createElement("a"),this.jv.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.im()}`,this.jv.title="Charting by TradingView",this.jv.id="tv-attr-logo",this.jv.target="_blank",this.jv.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.jv.toggleAttribute("data-dark",this.Yv==="dark"),this.Kv.appendChild(this.qv),this.Kv.appendChild(this.jv)))}}function ns(e,t){const n=K(e.ownerDocument).createElement("canvas");e.appendChild(n);const s=vv(n,{options:{allowResizeObserver:!0},transform:(i,r)=>({width:Math.max(i.width,r.width),height:Math.max(i.height,r.height)})});return s.resizeCanvasElement(t),s}function ss(e){var t;e.width=1,e.height=1,(t=e.getContext("2d"))==null||t.clearRect(0,0,1,1)}function xr(e,t,n,s){e.qh&&e.qh(t,n,s)}function fi(e,t,n,s){e.st(t,n,s)}function Ca(e,t,n,s){nm(e(n,s),t,s)}function nm(e,t,n){for(const s of e){const i=s.Tt(n);i!==null&&t(i)}}function jo(e,t){return n=>{var s,i;return function(r){return r.Ft!==void 0}(n)?(((s=n.Ft())==null?void 0:s.pl())??"")!==t?[]:((i=n.Qa)==null?void 0:i.call(n,e))??[]:[]}}function du(e,t,n,s){if(!e.length)return;let i=0;const r=e[0].$t(s,!0);let o=t===1?n/2-(e[0].Hi()-r/2):e[0].Hi()-r/2-n/2;o=Math.max(0,o);for(let l=1;l<e.length;l++){const c=e[l],h=e[l-1],a=h.$t(s,!1),u=c.Hi(),f=h.Hi();if(t===1?u>f-a:u<f+a){const p=f-a*t;c.Ui(p);const g=p-t*a/2;if((t===1?g<0:g>n)&&o>0){const d=t===1?-1-g:g-n,w=Math.min(d,o);for(let C=i;C<e.length;C++)e[C].Ui(e[C].Hi()+t*w);o-=w}}else i=l,o=t===1?f-a-u:u-(f+a)}}class fu{constructor(t,n,s,i){this.Ki=null,this.nm=null,this.sm=!1,this.rm=new Dr(200),this.hm=null,this.am=0,this.lm=!1,this.om=()=>{this.lm||this.yt._m().Qt().mr()},this.um=()=>{this.lm||this.yt._m().Qt().mr()},this.yt=t,this.yn=n,this.Ro=n.layout,this.bd=s,this.dm=i==="left",this.fm=jo("normal",i),this.pm=jo("top",i),this.vm=jo("bottom",i),this.uv=document.createElement("div"),this.uv.style.height="100%",this.uv.style.overflow="hidden",this.uv.style.width="25px",this.uv.style.left="0",this.uv.style.position="relative",this.wm=ns(this.uv,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const r=this.wm.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.Mm=ns(this.uv,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const o=this.Mm.canvasElement;o.style.position="absolute",o.style.zIndex="2",o.style.left="0",o.style.top="0";const l={Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Wp:this.gm.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this),fp:this.bm.bind(this),_p:this.bm.bind(this),bp:this.Sm.bind(this),Zp:this.bv.bind(this)};this.sv=new Zr(this.Mm.canvasElement,l,{Pp:()=>!this.yn.handleScroll.vertTouchDrag,kp:()=>!0})}m(){this.sv.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose(),this.Ki!==null&&this.Ki.__().u(this),this.Ki=null}fv(){return this.uv}P(){return this.Ro.fontSize}xm(){const t=this.bd.N();return this.hm!==t.k&&(this.rm.Os(),this.hm=t.k),t}Cm(){if(this.Ki===null)return 0;let t=0;const n=this.xm(),s=K(this.wm.canvasElement.getContext("2d",{colorSpace:this.yt._m().N().layout.colorSpace}));s.save();const i=this.Ki.zl();s.font=this.ym(),i.length>0&&(t=Math.max(this.rm.Ii(s,i[0].eo),this.rm.Ii(s,i[i.length-1].eo)));const r=this.Pm();for(let h=r.length;h--;){const a=this.rm.Ii(s,r[h].ri());a>t&&(t=a)}const o=this.Ki.Lt();if(o!==null&&this.nm!==null&&(l=this.yn.crosshair).mode!==2&&l.horzLine.visible&&l.horzLine.labelVisible){const h=this.Ki.Tn(1,o),a=this.Ki.Tn(this.nm.height-2,o);t=Math.max(t,this.rm.Ii(s,this.Ki.Ji(Math.floor(Math.min(h,a))+.11111111111111,o)),this.rm.Ii(s,this.Ki.Ji(Math.ceil(Math.max(h,a))-.11111111111111,o)))}var l;s.restore();const c=t||34;return Sa(Math.ceil(n.S+n.C+n.V+n.B+5+c))}km(t){this.nm!==null&&Zn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`)}Tm(){return K(this.nm).width}un(t){this.Ki!==t&&(this.Ki!==null&&this.Ki.__().u(this),this.Ki=t,t.__().i(this.wo.bind(this),this))}Ft(){return this.Ki}Os(){const t=this.yt.yv();this.yt._m().Qt().au(t,K(this.Ft()))}Rm(t){if(this.nm===null)return;const n={colorSpace:this.yt._m().N().layout.colorSpace};if(t!==1){this.Dm(),this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r),this.Vm(r)}),this.yt.Bm(i,this.vm),this.Em(i),this.yt.Bm(i,this.fm),this.Am(i))}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Lm(s),this.yt.Bm(s,this.pm))}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t.drawImage(o,n,s)}}Pt(){var t;(t=this.Ki)==null||t.zl()}Sv(t){if(this.Ki===null||this.Ki.Zi()||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv();this.sm=!0,n.Q_(s,this.Ki,t.localY)}xv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv(),i=this.Ki;n.tu(s,i,t.localY)}gm(){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const t=this.yt._m().Qt(),n=this.yt.yv(),s=this.Ki;this.sm&&(this.sm=!1,t.iu(n,s))}Cv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv();this.sm=!1,n.iu(s,this.Ki)}bm(t){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}Sm(t){this.Ki!==null&&(!this.yt._m().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.je()||this.Ki.No()||this.zm(1))}bv(t){this.zm(0)}Pm(){const t=[],n=this.Ki===null?void 0:this.Ki;return(s=>{for(let i=0;i<s.length;++i){const r=s[i].qn(this.yt.yv(),n);for(let o=0;o<r.length;o++)t.push(r[o])}})(this.yt.yv().Dt()),t}Im({context:t,bitmapSize:n}){const{width:s,height:i}=n,r=this.yt.yv().Qt(),o=r.$(),l=r.af();o===l?Yr(t,0,0,s,i,o):jf(t,0,0,s,i,o,l)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:s}){if(this.nm===null||this.Ki===null||!this.Ki.N().borderVisible)return;t.fillStyle=this.Ki.N().borderColor;const i=Math.max(1,Math.floor(this.xm().S*s));let r;r=this.dm?n.width-i:0,t.fillRect(r,0,i,n.height)}Em(t){if(this.nm===null||this.Ki===null)return;const n=this.Ki.zl(),s=this.Ki.N(),i=this.xm(),r=this.dm?this.nm.width-i.C:0;s.borderVisible&&s.ticksVisible&&t.useBitmapCoordinateSpace(({context:o,horizontalPixelRatio:l,verticalPixelRatio:c})=>{o.fillStyle=s.borderColor;const h=Math.max(1,Math.floor(c)),a=Math.floor(.5*c),u=Math.round(i.C*l);o.beginPath();for(const f of n)o.rect(Math.floor(r*l),Math.round(f.Vl*c)-a,u,h);o.fill()}),t.useMediaCoordinateSpace(({context:o})=>{o.font=this.ym(),o.fillStyle=s.textColor??this.Ro.textColor,o.textAlign=this.dm?"right":"left",o.textBaseline="middle";const l=this.dm?Math.round(r-i.V):Math.round(r+i.C+i.V),c=n.map(h=>this.rm.Di(o,h.eo));for(let h=n.length;h--;){const a=n[h];o.fillText(a.eo,l,a.Vl+c[h])}})}Dm(){if(this.nm===null||this.Ki===null)return;let t=this.nm.height/2;const n=[],s=this.Ki.Dt().slice(),i=this.yt.yv(),r=this.xm();this.Ki===i.Zs()&&this.yt.yv().Dt().forEach(c=>{i.Gs(c)&&s.push(c)});const o=this.Ki.kl()[0],l=this.Ki;s.forEach(c=>{const h=c.qn(i,l);h.forEach(a=>{a.$i()&&a.Wi()===null&&(a.Ui(null),n.push(a))}),o===c&&h.length>0&&(t=h[0].Ei())}),this.Ki.N().alignLabels&&this.Om(n,r,t)}Om(t,n,s){if(this.nm===null)return;const i=t.filter(o=>o.Ei()<=s),r=t.filter(o=>o.Ei()>s);i.sort((o,l)=>l.Ei()-o.Ei()),i.length&&r.length&&r.push(i[0]),r.sort((o,l)=>o.Ei()-l.Ei());for(const o of t){const l=Math.floor(o.$t(n)/2),c=o.Ei();c>-l&&c<l&&o.Ui(l),c>this.nm.height-l&&c<this.nm.height+l&&o.Ui(this.nm.height-l)}du(i,1,this.nm.height,n),du(r,-1,this.nm.height,n)}Am(t){if(this.nm===null)return;const n=this.Pm(),s=this.xm(),i=this.dm?"right":"left";n.forEach(r=>{r.ji()&&r.Tt(K(this.Ki)).st(t,s,this.rm,i)})}Lm(t){if(this.nm===null||this.Ki===null)return;const n=this.yt._m().Qt(),s=[],i=this.yt.yv(),r=n.Vd().qn(i,this.Ki);r.length&&s.push(r);const o=this.xm(),l=this.dm?"right":"left";s.forEach(c=>{c.forEach(h=>{h.Tt(K(this.Ki)).st(t,o,this.rm,l)})})}zm(t){this.uv.style.cursor=t===1?"ns-resize":"default"}wo(){const t=this.Cm();this.am<t&&this.yt._m().Qt().ka(),this.am=t}ym(){return Ir(this.Ro.fontSize,this.Ro.fontFamily)}}function Bx(e,t){var n;return((n=e.Xa)==null?void 0:n.call(e,t))??[]}function Vo(e,t){var n;return((n=e.jn)==null?void 0:n.call(e,t))??[]}function mu(e,t){var n;return((n=e.cn)==null?void 0:n.call(e,t))??[]}function Wx(e,t){var n;return((n=e.qa)==null?void 0:n.call(e,t))??[]}class Sl{constructor(t,n){this.nm=Nt({width:0,height:0}),this.Nm=null,this.Fm=null,this.Wm=null,this.Hm=null,this.Um=!1,this.$m=new Zt,this.jm=new Zt,this.qm=0,this.Ym=!1,this.Km=null,this.Gm=!1,this.Zm=null,this.Xm=null,this.lm=!1,this.om=()=>{this.lm||this.Jm===null||this.sn().mr()},this.um=()=>{this.lm||this.Jm===null||this.sn().mr()},this.Gv=t,this.Jm=n,this.Jm.mu().i(this.Qm.bind(this),this,!0),this.tw=document.createElement("td"),this.tw.style.padding="0",this.tw.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.iw=document.createElement("td"),this.iw.style.padding="0",this.nw=document.createElement("td"),this.nw.style.padding="0",this.tw.appendChild(s),this.wm=ns(s,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const i=this.wm.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Mm=ns(s,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const r=this.Mm.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0",this._v=document.createElement("tr"),this._v.appendChild(this.iw),this._v.appendChild(this.tw),this._v.appendChild(this.nw),this.sw(),this.sv=new Zr(this.Mm.canvasElement,this,{Pp:()=>this.Km===null&&!this.Gv.N().handleScroll.vertTouchDrag,kp:()=>this.Km===null&&!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.Nm!==null&&this.Nm.m(),this.Fm!==null&&this.Fm.m(),this.Wm=null,this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose(),this.Jm!==null&&(this.Jm.mu().u(this),this.Jm.m()),this.sv.m()}yv(){return K(this.Jm)}ew(t){var n;this.Jm!==null&&this.Jm.mu().u(this),this.Jm=t,this.Jm!==null&&this.Jm.mu().i(Sl.prototype.Qm.bind(this),this,!0),this.sw(),this.Gv.lv().indexOf(this)===this.Gv.lv().length-1?(this.Wm=this.Wm??new Fx(this.tw,this.Gv),this.Wm.Pt()):((n=this.Wm)==null||n.Xv(),this.Wm=null)}_m(){return this.Gv}fv(){return this._v}sw(){if(this.Jm!==null&&(this.rw(),this.sn().Jn().length!==0)){if(this.Nm!==null){const t=this.Jm.X_();this.Nm.un(K(t))}if(this.Fm!==null){const t=this.Jm.J_();this.Fm.un(K(t))}}}hw(){this.Nm!==null&&this.Nm.Pt(),this.Fm!==null&&this.Fm.Pt()}F_(){return this.Jm!==null?this.Jm.F_():0}W_(t){this.Jm&&this.Jm.W_(t)}bp(t){if(!this.Jm)return;this.aw();const n=t.localX,s=t.localY;this.lw(n,s,t)}Fp(t){this.aw(),this.ow(),this.lw(t.localX,t.localY,t)}Sp(t){if(!this.Jm)return;this.aw();const n=t.localX,s=t.localY;this.lw(n,s,t)}Ap(t){this.Jm!==null&&(this.aw(),this.lw(t.localX,t.localY,t),this._w(t))}fp(t){this.Jm!==null&&this.uw(this.jm,t)}_p(t){this.fp(t)}Dp(t){this.aw(),this.cw(t),this.lw(t.localX,t.localY,t)}Ep(t){this.Jm!==null&&(this.aw(),this.Ym=!1,this.dw(t))}Bp(t){this.Jm!==null&&this._w(t)}Xp(t){if(this.Ym=!0,this.Km===null){const n={x:t.localX,y:t.localY};this.fw(n,n,t)}}Zp(t){this.Jm!==null&&(this.aw(),this.Jm.Qt().Rd(null),this.pw())}mw(){return this.$m}ww(){return this.jm}$p(){this.qm=1,this.sn().cs()}jp(t,n){if(!this.Gv.N().handleScale.pinch)return;const s=5*(n-this.qm);this.qm=n,this.sn().Wd(t._t,s)}Op(t){this.Ym=!1,this.Gm=this.Km!==null,this.ow();const n=this.sn().Vd();this.Km!==null&&n.It()&&(this.Zm={x:n.ni(),y:n.si()},this.Km={x:t.localX,y:t.localY})}Tp(t){if(this.Jm===null)return;const n=t.localX,s=t.localY;if(this.Km===null)this.cw(t);else{this.Gm=!1;const i=K(this.Zm),r=i.x+(n-this.Km.x),o=i.y+(s-this.Km.y);this.lw(r,o,t)}}Vp(t){this._m().N().trackingMode.exitMode===0&&(this.Gm=!0),this.Mw(),this.dw(t)}Qs(t,n){const s=this.Jm;return s===null?null:Kf(s,t,n)}gw(t,n){K(n==="left"?this.Nm:this.Fm).km(Nt({width:t,height:this.nm.height}))}pv(){return this.nm}km(t){Zn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.tw.style.width=t.width+"px",this.tw.style.height=t.height+"px")}bw(){const t=K(this.Jm);t.G_(t.X_()),t.G_(t.J_());for(const n of t.kl())if(t.Gs(n)){const s=n.Ft();s!==null&&t.G_(s),n.Nn()}for(const n of t.Mu())n.Nn()}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t!==null&&t.drawImage(o,n,s)}}Rm(t){if(t===0||this.Jm===null)return;t>1&&this.bw(),this.Nm!==null&&this.Nm.Rm(t),this.Fm!==null&&this.Fm.Rm(t);const n={colorSpace:this.Gv.N().layout.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r)}),this.Jm&&(this.Sw(i,Bx),this.xw(i),this.Sw(i,Vo),this.Sw(i,mu)))}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Cw(s),this.Sw(s,Wx),this.Sw(s,mu))}yw(){return this.Nm}Pw(){return this.Fm}Bm(t,n){this.Sw(t,n)}Qm(){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=null}_w(t){this.uw(this.$m,t)}uw(t,n){const s=n.localX,i=n.localY;t.v()&&t.p(this.sn().Et().Vc(s),{x:s,y:i},n)}Im({context:t,bitmapSize:n}){const{width:s,height:i}=n,r=this.sn(),o=r.$(),l=r.af();o===l?Yr(t,0,0,s,i,l):jf(t,0,0,s,i,o,l)}xw(t){const n=K(this.Jm),s=n.wu().wr().Tt(n);s!==null&&s.st(t,!1)}Cw(t){this.kw(t,Vo,fi,this.sn().Vd())}Sw(t,n){const s=K(this.Jm),i=n===Vo?this.Tw():null,r=i===null?null:this.Rw(i,s),o=s.Mu();if(r===null||i===null){const h=s._u();return this.Dw(t,n,xr,o,h),void this.Dw(t,n,fi,o,h)}const l=s.Dt(),c=h=>h===i?r.Za:void 0;this.Dw(t,n,xr,o,l,c),this.Dw(t,n,fi,o,l,c),this.kw(t,n,xr,i,r.qa),this.kw(t,n,fi,i,r.qa)}Dw(t,n,s,i,r,o){for(const l of i)this.kw(t,n,s,l);if(o!==void 0)for(const l of r)this.kw(t,n,s,l,o(l));else for(const l of r)this.kw(t,n,s,l)}Tw(){var s;const t=K(this.Jm),n=(s=t.Qt().cu())==null?void 0:s.uu;if(!t.Qt().N().hoveredSeriesOnTop||n===void 0)return null;for(const i of t.Dt())if(i===n)return i;return null}Rw(t,n){var i;const s=((i=t.Ga)==null?void 0:i.call(t,n))??null;return s===null||s.qa.length===0?null:s}kw(t,n,s,i,r){const o=K(this.Jm),l=o.Qt().cu(),c=l!==null&&l.uu===i,h=l!==null&&c&&l.bu!==void 0?l.bu.ie:void 0,a=u=>s(u,t,c,h);r===void 0?Ca(n,a,i,o):nm(r,a,o)}rw(){if(this.Jm===null)return;const t=this.Gv,n=this.Jm.X_().N().visible,s=this.Jm.J_().N().visible;n||this.Nm===null||(this.iw.removeChild(this.Nm.fv()),this.Nm.m(),this.Nm=null),s||this.Fm===null||(this.nw.removeChild(this.Fm.fv()),this.Fm.m(),this.Fm=null);const i=t.Qt().Jd();n&&this.Nm===null&&(this.Nm=new fu(this,t.N(),i,"left"),this.iw.appendChild(this.Nm.fv())),s&&this.Fm===null&&(this.Fm=new fu(this,t.N(),i,"right"),this.nw.appendChild(this.Fm.fv()))}Iw(t){return t.Jp&&this.Ym||this.Km!==null}lw(t,n,s){t=Math.max(0,Math.min(t,this.nm.width-1)),n=Math.max(0,Math.min(n,this.nm.height-1)),this.sn().Kd(t,n,s,K(this.Jm))}pw(){this.sn().Zd()}Mw(){this.Gm&&(this.Km=null,this.pw())}fw(t,n,s){this.Km=t,this.Gm=!1,this.lw(n.x,n.y,s);const i=this.sn().Vd();this.Zm={x:i.ni(),y:i.si()}}sn(){return this.Gv.Qt()}dw(t){if(!this.Um)return;const n=this.sn(),s=this.yv();if(n.eu(s,s.kn()),this.Hm=null,this.Um=!1,n.jd(),this.Xm!==null){const i=performance.now(),r=n.Et();this.Xm.me(r.Oc(),i),this.Xm.Kc(i)||n.ps(this.Xm)}}aw(){this.Km=null}ow(){if(this.Jm){if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)K(document.activeElement).blur();else{const t=document.getSelection();t!==null&&t.removeAllRanges()}!this.Jm.kn().Zi()&&this.sn().Et().Zi()}}cw(t){if(this.Jm===null)return;const n=this.sn(),s=n.Et();if(s.Zi())return;const i=this.Gv.N(),r=i.handleScroll,o=i.kineticScroll;if((!r.pressedMouseMove||t.Jp)&&(!r.horzTouchDrag&&!r.vertTouchDrag||!t.Jp))return;const l=this.Jm.kn(),c=performance.now();if(this.Hm!==null||this.Iw(t)||(this.Hm={x:t.clientX,y:t.clientY,yf:c,Vw:t.localX,Bw:t.localY}),this.Hm!==null&&!this.Um&&(this.Hm.x!==t.clientX||this.Hm.y!==t.clientY)){if(t.Jp&&o.touch||!t.Jp&&o.mouse){const h=s.ml();this.Xm=new zx(.2/h,7/h,.997,15/h),this.Xm.Uv(s.Oc(),this.Hm.yf)}else this.Xm=null;l.Zi()||n.nu(this.Jm,l,t.localY),n.Ud(t.localX),this.Um=!0}this.Um&&(l.Zi()||n.su(this.Jm,l,t.localY),n.$d(t.localX),this.Xm!==null&&this.Xm.Uv(s.Oc(),c))}}class pu{constructor(t,n,s,i,r){this.xt=!0,this.nm=Nt({width:0,height:0}),this.om=()=>this.Rm(3),this.dm=t==="left",this.bd=s.Jd,this.yn=n,this.Ew=i,this.Aw=r,this.uv=document.createElement("div"),this.uv.style.width="25px",this.uv.style.height="100%",this.uv.style.overflow="hidden",this.wm=ns(this.uv,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om)}m(){this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose()}fv(){return this.uv}pv(){return this.nm}km(t){Zn(this.nm,t)||(this.nm=t,this.wm.resizeCanvasElement(t),this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.xt=!0)}Rm(t){if(t<3&&!this.xt||this.nm.width===0||this.nm.height===0)return;this.xt=!1,this.wm.applySuggestedBitmapSize();const n=ts(this.wm,{colorSpace:this.yn.layout.colorSpace});n!==null&&n.useBitmapCoordinateSpace(s=>{this.Im(s),this.Vm(s)})}vv(){return this.wm.bitmapSize}mv(t,n,s){const i=this.vv();i.width>0&&i.height>0&&t.drawImage(this.wm.canvasElement,n,s)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(!this.Ew())return;t.fillStyle=this.yn.timeScale.borderColor;const r=Math.floor(this.bd.N().S*s),o=Math.floor(this.bd.N().S*i),l=this.dm?n.width-r:0;t.fillRect(l,0,r,o)}Im({context:t,bitmapSize:n}){Yr(t,0,0,n.width,n.height,this.Aw())}}function Cl(e){return t=>{var n;return((n=t.tl)==null?void 0:n.call(t,e))??[]}}const jx=Cl("normal"),Vx=Cl("top"),Ox=Cl("bottom");class Ux{constructor(t,n){this.Lw=null,this.zw=null,this.M=null,this.Ow=!1,this.nm=Nt({width:0,height:0}),this.Nw=new Zt,this.rm=new Dr(5),this.lm=!1,this.om=()=>{this.lm||this.Gv.Qt().mr()},this.um=()=>{this.lm||this.Gv.Qt().mr()},this.Gv=t,this.Pu=n,this.yn=t.N().layout,this.jv=document.createElement("tr"),this.Fw=document.createElement("td"),this.Fw.style.padding="0",this.Ww=document.createElement("td"),this.Ww.style.padding="0",this.uv=document.createElement("td"),this.uv.style.height="25px",this.uv.style.padding="0",this.Hw=document.createElement("div"),this.Hw.style.width="100%",this.Hw.style.height="100%",this.Hw.style.position="relative",this.Hw.style.overflow="hidden",this.uv.appendChild(this.Hw),this.wm=ns(this.Hw,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const s=this.wm.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Mm=ns(this.Hw,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const i=this.Mm.canvasElement;i.style.position="absolute",i.style.zIndex="2",i.style.left="0",i.style.top="0",this.jv.appendChild(this.Fw),this.jv.appendChild(this.uv),this.jv.appendChild(this.Ww),this.Uw(),this.Gv.Qt().N_().i(this.Uw.bind(this),this),this.sv=new Zr(this.Mm.canvasElement,this,{Pp:()=>!0,kp:()=>!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.sv.m(),this.Lw!==null&&this.Lw.m(),this.zw!==null&&this.zw.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose()}fv(){return this.jv}$w(){return this.Lw}jw(){return this.zw}Fp(t){if(this.Ow)return;this.Ow=!0;const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.Fd(t.localX)}Op(t){this.Fp(t)}Wp(){const t=this.Gv.Qt();!t.Et().Zi()&&this.Ow&&(this.Ow=!1,this.Gv.N().handleScale.axisPressedMouseMove.time&&t.Yd())}Dp(t){const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.qd(t.localX)}Tp(t){this.Dp(t)}Ep(){this.Ow=!1;const t=this.Gv.Qt();t.Et().Zi()&&!this.Gv.N().handleScale.axisPressedMouseMove.time||t.Yd()}Vp(){this.Ep()}fp(){this.Gv.N().handleScale.axisDoubleClickReset.time&&this.Gv.Qt().ws()}_p(){this.fp()}bp(){this.Gv.Qt().N().handleScale.axisPressedMouseMove.time&&this.zm(1)}Zp(){this.zm(0)}pv(){return this.nm}qw(){return this.Nw}Yw(t,n,s){Zn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.Nw.p(t)),this.Lw!==null&&this.Lw.km(Nt({width:n,height:t.height})),this.zw!==null&&this.zw.km(Nt({width:s,height:t.height}))}Kw(){const t=this.Gw();return Math.ceil(t.S+t.C+t.P+t.A+t.I+t.Zw)}Pt(){this.Gv.Qt().Et().zl()}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t.drawImage(o,n,s)}}Rm(t){if(t===0)return;const n={colorSpace:this.yn.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r),this.Vm(r),this.Xw(i,Ox)}),this.Em(i),this.Xw(i,jx)),this.Lw!==null&&this.Lw.Rm(t),this.zw!==null&&this.zw.Rm(t)}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Jw([...this.Gv.Qt().Jn(),this.Gv.Qt().Vd()],s),this.Xw(s,Vx))}Xw(t,n){const s=this.Gv.Qt().Jn();for(const i of s)Ca(n,r=>xr(r,t,!1,void 0),i,void 0);for(const i of s)Ca(n,r=>fi(r,t,!1,void 0),i,void 0)}Im({context:t,bitmapSize:n}){Yr(t,0,0,n.width,n.height,this.Gv.Qt().af())}Vm({context:t,bitmapSize:n,verticalPixelRatio:s}){if(this.Gv.N().timeScale.borderVisible){t.fillStyle=this.Qw();const i=Math.max(1,Math.floor(this.Gw().S*s));t.fillRect(0,0,n.width,i)}}Em(t){const n=this.Gv.Qt().Et(),s=n.zl();if(!s||s.length===0)return;const i=this.Pu.maxTickMarkWeight(s),r=this.Gw(),o=n.N();o.borderVisible&&o.ticksVisible&&t.useBitmapCoordinateSpace(({context:l,horizontalPixelRatio:c,verticalPixelRatio:h})=>{l.strokeStyle=this.Qw(),l.fillStyle=this.Qw();const a=Math.max(1,Math.floor(c)),u=Math.floor(.5*c);l.beginPath();const f=Math.round(r.C*h);for(let p=s.length;p--;){const g=Math.round(s[p].coord*c);l.rect(g-u,0,a,f)}l.fill()}),t.useMediaCoordinateSpace(({context:l})=>{const c=r.S+r.C+r.A+r.P/2;l.textAlign="center",l.textBaseline="middle",l.fillStyle=this.H(),l.font=this.ym();for(const h of s)if(h.weight<i){const a=h.needAlignCoordinate?this.tM(l,h.coord,h.label):h.coord;l.fillText(h.label,a,c)}this.Gv.N().timeScale.allowBoldLabels&&(l.font=this.iM());for(const h of s)if(h.weight>=i){const a=h.needAlignCoordinate?this.tM(l,h.coord,h.label):h.coord;l.fillText(h.label,a,c)}})}tM(t,n,s){const i=this.rm.Ii(t,s),r=i/2,o=Math.floor(n-r)+.5;return o<0?n+=Math.abs(0-o):o+i>this.nm.width&&(n-=Math.abs(this.nm.width-(o+i))),n}Jw(t,n){const s=this.Gw();for(const i of t)for(const r of i.dn())r.Tt().st(n,s)}Qw(){return this.Gv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}ym(){return Ir(this.F(),this.yn.fontFamily)}iM(){return Ir(this.F(),this.yn.fontFamily,"bold")}Gw(){this.M===null&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,P:NaN,k:"",Qi:new Dr,Zw:0});const t=this.M,n=this.ym();if(t.k!==n){const s=this.F();t.P=s,t.k=n,t.A=3*s/12,t.I=3*s/12,t.tn=9*s/12,t.L=0,t.Zw=4*s/12,t.Qi.Os()}return this.M}zm(t){this.uv.style.cursor=t===1?"ew-resize":"default"}Uw(){const t=this.Gv.Qt(),n=t.N();n.leftPriceScale.visible||this.Lw===null||(this.Fw.removeChild(this.Lw.fv()),this.Lw.m(),this.Lw=null),n.rightPriceScale.visible||this.zw===null||(this.Ww.removeChild(this.zw.fv()),this.zw.m(),this.zw=null);const s={Jd:this.Gv.Qt().Jd()},i=()=>n.leftPriceScale.borderVisible&&t.Et().N().borderVisible,r=()=>t.af();n.leftPriceScale.visible&&this.Lw===null&&(this.Lw=new pu("left",n,s,i,r),this.Fw.appendChild(this.Lw.fv())),n.rightPriceScale.visible&&this.zw===null&&(this.zw=new pu("right",n,s,i,r),this.Ww.appendChild(this.zw.fv()))}}var Bu;const Hx=!!Vs&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(e=>e.brand.includes("Chromium"))&&!!Vs&&((Bu=navigator==null?void 0:navigator.userAgentData)!=null&&Bu.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);class qx{constructor(t,n,s){var i;this.nM=[],this.sM=[],this.eM=0,this.oo=0,this.k_=0,this.rM=0,this.hM=0,this.aM=null,this.lM=!1,this.$m=new Zt,this.jm=new Zt,this.wd=new Zt,this.oM=null,this._M=null,this.Kv=t,this.yn=n,this.Pu=s,this.jv=document.createElement("div"),this.jv.classList.add("tv-lightweight-charts"),this.jv.style.overflow="hidden",this.jv.style.direction="ltr",this.jv.style.width="100%",this.jv.style.height="100%",(i=this.jv).style.userSelect="none",i.style.webkitUserSelect="none",i.style.msUserSelect="none",i.style.MozUserSelect="none",i.style.webkitTapHighlightColor="transparent",this.uM=document.createElement("table"),this.uM.setAttribute("cellspacing","0"),this.jv.appendChild(this.uM),this.cM=this.dM.bind(this),Oo(this.yn)&&this.fM(!0),this.sn=new Rx(this.gd.bind(this),this.yn,s),this.Qt().Bd().i(this.pM.bind(this),this),this.vM=new Ux(this,this.Pu),this.uM.appendChild(this.vM.fv());const r=n.autoSize&&this.mM();let o=this.yn.width,l=this.yn.height;if(r||o===0||l===0){const c=t.getBoundingClientRect();o=o||c.width,l=l||c.height}this.wM(o,l),this.MM(),t.appendChild(this.jv),this.gM(),this.sn.Et().Jc().i(this.sn.ka.bind(this.sn),this),this.sn.N_().i(this.sn.ka.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}lv(){return this.nM}bM(){return this.vM}m(){this.fM(!1),this.eM!==0&&window.cancelAnimationFrame(this.eM),this.sn.Bd().u(this),this.sn.Et().Jc().u(this),this.sn.N_().u(this),this.sn.m();for(const t of this.nM)this.uM.removeChild(t.fv()),t.mw().u(this),t.ww().u(this),t.m();this.nM=[];for(const t of this.sM)this.SM(t);this.sM=[],K(this.vM).m(),this.jv.parentElement!==null&&this.jv.parentElement.removeChild(this.jv),this.wd.m(),this.$m.m(),this.jm.m(),this.xM()}wM(t,n,s=!1){if(this.oo===n&&this.k_===t)return;const i=function(l){const c=Math.floor(l.width),h=Math.floor(l.height);return Nt({width:c-c%2,height:h-h%2})}(Nt({width:t,height:n}));this.oo=i.height,this.k_=i.width;const r=this.oo+"px",o=this.k_+"px";if(this.CM()||(K(this.jv).style.height=r,K(this.jv).style.width=o),this.uM.style.height=r,this.uM.style.width=o,s){this.eM!==0&&(window.cancelAnimationFrame(this.eM),this.eM=0),this.lM=!1;const l=fe.ys();this.aM!==null&&(l.Ss(this.aM),this.aM=null),this.yM(l,performance.now())}else this.sn.ka()}Rm(t){t===void 0&&(t=fe.ys());for(let n=0;n<this.nM.length;n++)this.nM[n].Rm(t._s(n).rs);this.yn.timeScale.visible&&this.vM.Rm(t.ls())}vr(t){var i;const n=Oo(this.yn);this.sn.vr(t);const s=Oo(this.yn);s!==n&&this.fM(s),(i=t.layout)!=null&&i.panes&&this.PM(),this.gM(),this.kM(t)}mw(){return this.$m}ww(){return this.jm}Bd(){return this.wd}TM(t=!1){this.aM!==null&&(this.yM(this.aM,performance.now()),this.aM=null);const n=this.RM(null),s=document.createElement("canvas");s.width=n.width,s.height=n.height;const i=K(s.getContext("2d"));return this.RM(i,t),s}DM(t){return t==="left"&&!this.IM()||t==="right"&&!this.VM()||this.nM.length===0?0:K(t==="left"?this.nM[0].yw():this.nM[0].Pw()).Tm()}CM(){return this.yn.autoSize&&this.oM!==null}Mv(){return this.jv}BM(t){this._M=t,this._M?this.Mv().style.setProperty("cursor",t):this.Mv().style.removeProperty("cursor")}EM(){return this._M}AM(t){return Re(this.nM[t]).pv()}PM(){this.sM.forEach(t=>{t.Pt()})}kM(t){(t.autoSize!==void 0||!this.oM||t.width===void 0&&t.height===void 0)&&(t.autoSize&&!this.oM&&this.mM(),t.autoSize===!1&&this.oM!==null&&this.xM(),t.autoSize||t.width===void 0&&t.height===void 0||this.wM(t.width||this.k_,t.height||this.oo))}RM(t,n){let s=0,i=0;const r=this.nM[0],o=(c,h)=>{let a=0;for(let u=0;u<this.nM.length;u++){const f=this.nM[u],p=K(c==="left"?f.yw():f.Pw()),g=p.vv();if(t!==null&&p.mv(t,h,a,n),a+=g.height,u<this.nM.length-1){const d=this.sM[u],w=d.vv();t!==null&&d.mv(t,h,a),a+=w.height}}};this.IM()&&(o("left",0),s+=K(r.yw()).vv().width);for(let c=0;c<this.nM.length;c++){const h=this.nM[c],a=h.vv();if(t!==null&&h.mv(t,s,i,n),i+=a.height,c<this.nM.length-1){const u=this.sM[c],f=u.vv();t!==null&&u.mv(t,s,i),i+=f.height}}s+=r.vv().width,this.VM()&&(o("right",s),s+=K(r.Pw()).vv().width);const l=(c,h,a)=>{K(c==="left"?this.vM.$w():this.vM.jw()).mv(K(t),h,a)};if(this.yn.timeScale.visible){const c=this.vM.vv();if(t!==null){let h=0;this.IM()&&(l("left",h,i),h=K(r.yw()).vv().width),this.vM.mv(t,h,i,n),h+=c.width,this.VM()&&l("right",h,i)}i+=c.height}return Nt({width:s,height:i})}LM(){let t=0,n=0,s=0;for(const w of this.nM)this.IM()&&(n=Math.max(n,K(w.yw()).Cm(),this.yn.leftPriceScale.minimumWidth)),this.VM()&&(s=Math.max(s,K(w.Pw()).Cm(),this.yn.rightPriceScale.minimumWidth)),t+=w.F_();n=Sa(n),s=Sa(s);const i=this.k_,r=this.oo,o=Math.max(i-n-s,0),l=1*this.sM.length,c=this.yn.timeScale.visible;let h=c?Math.max(this.vM.Kw(),this.yn.timeScale.minimumHeight):0;var a;h=(a=h)+a%2;const u=l+h,f=r<u?0:r-u,p=f/t;let g=0;const d=window.devicePixelRatio||1;for(let w=0;w<this.nM.length;++w){const C=this.nM[w];C.ew(this.sn.Gn()[w]);let x=0,k=0;k=w===this.nM.length-1?Math.ceil((f-g)*d)/d:Math.round(C.F_()*p*d)/d,x=Math.max(k,2),g+=x,C.km(Nt({width:o,height:x})),this.IM()&&C.gw(n,"left"),this.VM()&&C.gw(s,"right"),C.yv()&&this.sn.Ed(C.yv(),x)}this.vM.Yw(Nt({width:c?o:0,height:h}),c?n:0,c?s:0),this.sn.H_(o),this.rM!==n&&(this.rM=n),this.hM!==s&&(this.hM=s)}fM(t){t?this.jv.addEventListener("wheel",this.cM,{passive:!1}):this.jv.removeEventListener("wheel",this.cM)}zM(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Hx?1/window.devicePixelRatio:1}dM(t){if(!(t.deltaX!==0&&this.yn.handleScroll.mouseWheel||t.deltaY!==0&&this.yn.handleScale.mouseWheel))return;const n=this.zM(t),s=n*t.deltaX/100,i=-n*t.deltaY/100;if(t.cancelable&&t.preventDefault(),i!==0&&this.yn.handleScale.mouseWheel){const r=Math.sign(i)*Math.min(1,Math.abs(i)),o=t.clientX-this.jv.getBoundingClientRect().left;this.Qt().Wd(o,r)}s!==0&&this.yn.handleScroll.mouseWheel&&this.Qt().Hd(-80*s)}yM(t,n){var i;const s=t.ls();s===3&&this.OM(),s!==3&&s!==2||(this.NM(t),this.FM(t,n),this.vM.Pt(),this.nM.forEach(r=>{r.hw()}),((i=this.aM)==null?void 0:i.ls())===3&&(this.aM.Ss(t),this.OM(),this.NM(this.aM),this.FM(this.aM,n),t=this.aM,this.aM=null)),this.Rm(t)}FM(t,n){for(const s of t.bs())this.xs(s,n)}NM(t){const n=this.sn.Gn();for(let s=0;s<n.length;s++)t._s(s).hs&&n[s].lu()}xs(t,n){const s=this.sn.Et();switch(t.ds){case 0:s.td();break;case 1:s.nd(t.Wt);break;case 2:s.Ms(t.Wt);break;case 3:s.gs(t.Wt);break;case 4:s.Wc();break;case 5:t.Wt.Kc(n)||s.gs(t.Wt.Gc(n))}}gd(t){this.aM!==null?this.aM.Ss(t):this.aM=t,this.lM||(this.lM=!0,this.eM=window.requestAnimationFrame(n=>{if(this.lM=!1,this.eM=0,this.aM!==null){const s=this.aM;this.aM=null,this.yM(s,n);for(const i of s.bs())if(i.ds===5&&!i.Wt.Kc(n)){this.Qt().ps(i.Wt);break}}}))}OM(){this.MM()}SM(t){this.uM.removeChild(t.fv()),t.m()}MM(){const t=this.sn.Gn(),n=t.length,s=this.nM.length;for(let i=n;i<s;i++){const r=Re(this.nM.pop());this.uM.removeChild(r.fv()),r.mw().u(this),r.ww().u(this),r.m();const o=this.sM.pop();o!==void 0&&this.SM(o)}for(let i=s;i<n;i++){const r=new Sl(this,t[i]);if(r.mw().i(this.WM.bind(this,r),this),r.ww().i(this.HM.bind(this,r),this),this.nM.push(r),i>0){const o=new Lx(this,i-1,i);this.sM.push(o),this.uM.insertBefore(o.fv(),this.vM.fv())}this.uM.insertBefore(r.fv(),this.vM.fv())}for(let i=0;i<n;i++){const r=t[i],o=this.nM[i];o.yv()!==r?o.ew(r):o.sw()}this.gM(),this.LM()}UM(t,n,s,i){var a;const r=new Map;t!==null&&this.sn.Jn().forEach(u=>{const f=u.Un().Hn(t);f!==null&&r.set(u,f)});let o;if(t!==null){const u=(a=this.sn.Et().en(t))==null?void 0:a.originalTime;u!==void 0&&(o=u)}const l=this.Qt().cu(),c=this.$M(i),h=function(u,f){var x;const p=u!==null&&u.uu instanceof Kr?u.uu:void 0,g=(x=u==null?void 0:u.bu)==null?void 0:x.te,d=f!==void 0&&f!==-1?f:void 0;return u===null||u.ee===void 0?{jM:p,qM:g}:{jM:p,qM:g,YM:{ds:u.ee,KM:(w=u.uu,C=u.ee,w instanceof va?"pane-primitive":C==="marker"||C==="primitive"?"series-primitive":"series"),GM:Ix(u.ee,g),Y_:p,ZM:g,XM:d}};var w,C}(l,c);return{Qr:o,$n:t??void 0,JM:n??void 0,XM:c!==-1?c:void 0,jM:h.jM,QM:r,qM:h.qM,YM:h.YM,tg:s??void 0}}$M(t){let n=-1;if(t)n=this.nM.indexOf(t);else{const s=this.Qt().Vd().Kn();s!==null&&(n=this.Qt().Gn().indexOf(s))}return n}WM(t,n,s,i){this.$m.p(()=>this.UM(n,s,i,t))}HM(t,n,s,i){this.jm.p(()=>this.UM(n,s,i,t))}pM(t,n,s){var i;this.BM(((i=this.Qt().cu())==null?void 0:i.gu)??null),this.wd.p(()=>this.UM(t,n,s))}gM(){const t=this.yn.timeScale.visible?"":"none";this.vM.fv().style.display=t}IM(){return this.nM[0].yv().X_().N().visible}VM(){return this.nM[0].yv().J_().N().visible}mM(){return"ResizeObserver"in window&&(this.oM=new ResizeObserver(t=>{const n=t[t.length-1];if(!n)return;const s=n.contentRect.width,i=n.contentRect.height;this.wM(s,i,!0)}),this.oM.observe(this.Kv,{box:"border-box"}),!0)}xM(){this.oM!==null&&this.oM.disconnect(),this.oM=null}}function Oo(e){return!!(e.handleScroll.mouseWheel||e.handleScale.mouseWheel)}function Gx(e){return e.open===void 0&&e.value===void 0}function Yx(e){return function(t){return t.open!==void 0}(e)||function(t){return t.value!==void 0}(e)}function gu(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.color!==void 0&&(r.R=n.color),r}function Xx(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.lineColor!==void 0&&(r.vt=n.lineColor),n.topColor!==void 0&&(r.ah=n.topColor),n.bottomColor!==void 0&&(r.oh=n.bottomColor),r}function Qx(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.topLineColor!==void 0&&(r._h=n.topLineColor),n.bottomLineColor!==void 0&&(r.uh=n.bottomLineColor),n.topFillColor1!==void 0&&(r.dh=n.topFillColor1),n.topFillColor2!==void 0&&(r.fh=n.topFillColor2),n.bottomFillColor1!==void 0&&(r.ph=n.bottomFillColor1),n.bottomFillColor2!==void 0&&(r.mh=n.bottomFillColor2),r}function Jx(e,t,n,s){const i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:s};return n.color!==void 0&&(i.R=n.color),i}function Kx(e,t,n,s){const i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:s};return n.color!==void 0&&(i.R=n.color),n.borderColor!==void 0&&(i.Ht=n.borderColor),n.wickColor!==void 0&&(i.hh=n.wickColor),i}function Zx(e,t,n,s,i){const r=Re(i)(n),o=Math.max(...r),l=Math.min(...r),c=r[r.length-1],h=[c,o,l,c],{time:a,color:u,...f}=n;return{$n:t,wt:e,Wt:h,Qr:s,ue:f,R:u}}function Es(e){return e.Wt!==void 0}function yu(e,t){return t.customValues!==void 0&&(e.ig=t.customValues),e}function Gn(e){return(t,n,s,i,r,o)=>function(l,c){return c?c(l):Gx(l)}(s,o)?yu({wt:t,$n:n,Qr:i},s):yu(e(t,n,s,i,r),s)}function bu(e){return{Candlestick:Gn(Kx),Bar:Gn(Jx),Area:Gn(Xx),Baseline:Gn(Qx),Histogram:Gn(gu),Line:Gn(gu),Custom:Gn(Zx)}[e]}function vu(e){return{$n:0,ng:new Map,Oa:e}}function xu(e,t){if(e!==void 0&&e.length!==0)return{sg:t.key(e[0].wt),eg:t.key(e[e.length-1].wt)}}function wu(e){let t;return e.forEach(n=>{t===void 0&&(t=n.Qr)}),Re(t)}class tw{constructor(t){this.rg=new Map,this.hg=new Map,this.ag=new Map,this.lg=[],this.Pu=t}m(){this.rg.clear(),this.hg.clear(),this.ag.clear(),this.lg=[]}og(t,n){let s=this.rg.size!==0,i=!1;const r=this.hg.get(t);if(r!==void 0)if(this.hg.size===1)s=!1,i=!0,this.rg.clear();else for(const c of this.lg)c.pointData.ng.delete(t)&&(i=!0);let o=[];if(n.length!==0){const c=n.map(p=>p.time),h=this.Pu.createConverterToInternalObj(n),a=bu(t.bh()),u=t.ul(),f=t.cl();o=n.map((p,g)=>{const d=h(p.time),w=this.Pu.key(d);let C=this.rg.get(w);C===void 0&&(C=vu(d),this.rg.set(w,C),i=!0);const x=a(d,C.$n,p,c[g],u,f);return C.ng.set(t,x),x})}s&&this._g(),this.ug(t,o);let l=-1;if(i){const c=[];this.rg.forEach(h=>{c.push({timeWeight:0,time:h.Oa,pointData:h,originalTime:wu(h.ng)})}),c.sort((h,a)=>this.Pu.key(h.time)-this.Pu.key(a.time)),l=this.cg(c)}return this.dg(t,l,function(c,h,a){const u=xu(c,a),f=xu(h,a);if(u!==void 0&&f!==void 0)return{fg:!1,Va:u.eg>=f.eg&&u.sg>=f.sg}}(this.hg.get(t),r,this.Pu))}if(t){return this.og(t,[])}pg(t,n,s){if(s&&t.Fa())throw new Error("Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.");const i=n;(function(C){C.Qr===void 0&&(C.Qr=C.time)})(i),this.Pu.preprocessData(n);const r=this.Pu.createConverterToInternalObj([n])(n.time),o=this.ag.get(t);if(!s&&o!==void 0&&this.Pu.key(r)<this.Pu.key(o))throw new Error(`Cannot update oldest data, last time=${o}, new time=${r}`);let l=this.rg.get(this.Pu.key(r));if(s&&l===void 0)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const c=l===void 0;l===void 0&&(l=vu(r),this.rg.set(this.Pu.key(r),l));const h=bu(t.bh()),a=t.ul(),u=t.cl(),f=h(r,l.$n,n,i.Qr,a,u),p=!s&&!c&&o!==void 0&&this.Pu.key(r)===this.Pu.key(o);l.ng.set(t,f),s?this.vg(t,f,l.$n):p&&t.Fa()&&Es(f)?(t.Rr(f),this.mg(t,f)):this.mg(t,f);const g={Va:Es(f),fg:s};if(!c)return this.dg(t,-1,g);const d={timeWeight:0,time:l.Oa,pointData:l,originalTime:wu(l.ng)},w=es(this.lg,this.Pu.key(d.time),(C,x)=>this.Pu.key(C.time)<x);this.lg.splice(w,0,d);for(let C=w;C<this.lg.length;++C)pr(this.lg[C].pointData,C);return this.Pu.fillWeightsForPoints(this.lg,w),this.dg(t,w,g)}wg(t,n){const s=this.hg.get(t);if(s===void 0||n<=0)return[[],this.Mg()];n=Math.min(n,s.length);const i=s.splice(-n).reverse();s.length===0?this.ag.delete(t):this.ag.set(t,s[s.length-1].wt);for(const r of i){const o=this.rg.get(this.Pu.key(r.wt));if(o&&(o.ng.delete(t),o.ng.size===0)){this.rg.delete(this.Pu.key(o.Oa)),this.lg.splice(o.$n,1);for(let l=o.$n;l<this.lg.length;++l)pr(this.lg[l].pointData,l)}}return[i,this.dg(t,this.lg.length-1,{fg:!1,Va:!1})]}mg(t,n){let s=this.hg.get(t);s===void 0&&(s=[],this.hg.set(t,s));const i=s.length!==0?s[s.length-1]:null;i===null||this.Pu.key(n.wt)>this.Pu.key(i.wt)?Es(n)&&s.push(n):Es(n)?s[s.length-1]=n:s.splice(-1,1),this.ag.set(t,n.wt)}vg(t,n,s){const i=this.hg.get(t);if(i===void 0)return;const r=es(i,s,(o,l)=>o.$n<l);Es(n)?i[r]=n:i.splice(r,1)}ug(t,n){n.length!==0?(this.hg.set(t,n.filter(Es)),this.ag.set(t,n[n.length-1].wt)):(this.hg.delete(t),this.ag.delete(t))}_g(){for(const t of this.lg)t.pointData.ng.size===0&&this.rg.delete(this.Pu.key(t.time))}cg(t){let n=-1;for(let s=0;s<this.lg.length&&s<t.length;++s){const i=this.lg[s],r=t[s];if(this.Pu.key(i.time)!==this.Pu.key(r.time)){n=s;break}r.timeWeight=i.timeWeight,pr(r.pointData,s)}if(n===-1&&this.lg.length!==t.length&&(n=Math.min(this.lg.length,t.length)),n===-1)return-1;for(let s=n;s<t.length;++s)pr(t[s].pointData,s);return this.Pu.fillWeightsForPoints(t,n),this.lg=t,n}gg(){if(this.hg.size===0)return null;let t=0;return this.hg.forEach(n=>{n.length!==0&&(t=Math.max(t,n[n.length-1].$n))}),t}dg(t,n,s){const i=this.Mg();if(n!==-1)this.hg.forEach((r,o)=>{i.Y_.set(o,{ue:r,bg:o===t?s:void 0})}),this.hg.has(t)||i.Y_.set(t,{ue:[],bg:s}),i.Et.Sg=this.lg,i.Et.xg=n;else{const r=this.hg.get(t);i.Y_.set(t,{ue:r||[],bg:s})}return i}Mg(){return{Y_:new Map,Et:{Dc:this.gg()}}}}function pr(e,t){e.$n=t,e.ng.forEach(n=>{n.$n=t})}function ew(e,t){return e._t<t}function nw(e,t){return t<e._t}function ka(e,t,n,s){return es(e,t,ew,n,s)}function Ma(e,t,n,s){return xl(e,t,nw,n,s)}function wr(e,t,n){return{ne:e,se:t,ee:n}}function Su(e,t,n,s){return e>=t-s&&e<=n+s}function mi(e,t,n,s,i,r){const o=i-n,l=r-s;if(o===0&&l===0)return Math.hypot(e-n,t-s);const c=((e-n)*o+(t-s)*l)/(o*o+l*l),h=Math.max(0,Math.min(1,c)),a=n+o*h,u=s+l*h;return Math.hypot(e-a,t-u)}const Uo=[0,0];function sw(e,t,n){return t===void 0||t.wt!==e.wt-1?e._t-n/2:(t._t+e._t)/2}function iw(e,t,n){return t===void 0||t.wt!==e.wt+1?e._t+n/2:(e._t+t._t)/2}function sm(e,t,n,s,i,r,o){if(t===null||t.from>=t.to||e.length===0)return null;const l=i/2+r,c=ka(e,n-l,t.from,t.to),h=Ma(e,n+l,c,t.to);if(c>=h)return null;let a=Number.POSITIVE_INFINITY;for(let u=c;u<h;u++){const f=e[u],p=u>t.from?e[u-1]:void 0,g=u<t.to-1?e[u+1]:void 0,d=sw(f,p,i)-r,w=iw(f,g,i)+r;if(n<d||n>w)continue;o(f,Uo);const C=Uo[0],x=Uo[1],k=Math.min(C,x),S=Math.max(C,x),T=k-r,P=S+r;if(s>=k&&s<=S)a=Math.min(a,0);else if(s>=T&&s<=P){const I=Math.min(Math.abs(s-k),Math.abs(S-s));a=Math.min(a,I)}}return Number.isFinite(a)?wr(a,0,"series-range"):null}function rw(e,t){return e.wt<t}function ow(e,t){return t<e.wt}function aw(e,t,n){const s=t.Na(),i=t.bi(),r=es(e,s,rw),o=xl(e,i,ow);if(!n)return{from:r,to:o};let l=r,c=o;return r>0&&r<e.length&&e[r].wt>=s&&(l=r-1),o>0&&o<e.length&&e[o-1].wt<=i&&(c=o+1),{from:l,to:c}}class kl{constructor(t,n,s){this.Cg=!0,this.yg=!0,this.Pg=!0,this.kg=[],this.Tg=null,this.Rg=-1,this.ae=t,this.le=n,this.Dg=s}Pt(t){this.Cg=!0,t==="data"&&(this.yg=!0),t==="options"&&(this.Pg=!0)}Tt(){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Vg):null}Qs(t,n){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Bg(t,n)):null}Bg(t,n){return null}Eg(){this.kg=this.kg.map(t=>({...t,...this.ae.Sa().Sh(t.wt)}))}Ag(){this.Tg=null}Ig(){const t=this.le.Et(),n=t.N().enableConflation?t.sd():0;n!==this.Rg&&(this.yg=!0,this.Rg=n),this.yg&&(this.Lg(),this.yg=!1),this.Pg&&(this.Eg(),this.Pg=!1),this.Cg&&(this.zg(),this.Cg=!1)}zg(){const t=this.ae.Ft(),n=this.le.Et();if(this.Ag(),n.Zi()||t.Zi())return;const s=n.Ee();if(s===null||this.ae.Un().Th()===0)return;const i=this.ae.Lt();i!==null&&(this.Tg=aw(this.kg,s,this.Dg),this.Og(t,n,i.Wt),this.Ng())}}class lw{constructor(t,n){this.Fg=t,this.Ki=n}st(t,n,s){this.Fg.draw(t,this.Ki,n,s)}}function cw(e){switch(e){case"point":return 2;case"range":return 0;default:return 1}}class hw extends kl{constructor(t,n,s){super(t,n,!1),this.Yh=s,this.Fg=this.Yh.renderer(),this.Vg=new lw(this.Fg,i=>this.Wg(i))}get ga(){return this.Yh.conflationReducer}Ha(t){return this.Yh.priceValueBuilder(t)}dl(t){return this.Yh.isWhitespace(t)}Bg(t,n){var o,l;const s=(l=(o=this.Fg).hitTest)==null?void 0:l.call(o,t,n,c=>this.Wg(c));if(s!=null)return{ne:(i=s).distance,se:cw(i.type),ee:"custom",gu:i.cursorStyle,te:i.objectId,ie:i.hitTestData};var i;const r=sm(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(c,h)=>{const a=c.Hg;let u=NaN,f=NaN;if(a!==void 0&&!this.Yh.isWhitespace(a))for(const p of this.Yh.priceValueBuilder(a)){const g=this.Wg(p);g!==null&&(u=Number.isNaN(u)?g:Math.min(u,g),f=Number.isNaN(f)?g:Math.max(f,g))}h[0]=u,h[1]=f});return r===null?null:{...r,ee:"custom"}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>({wt:n.$n,_t:NaN,...t.Sh(n.$n),Hg:n.ue}))}Og(t,n){n.Ic(this.kg,Ni(this.Tg))}Ng(){this.Yh.update({bars:this.kg.map(uw),barSpacing:this.le.Et().ml(),visibleRange:this.Tg,conflationFactor:this.le.Et().sd()},this.ae.N())}Wg(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}}function uw(e){return{x:e._t,time:e.wt,originalData:e.Hg,barColor:e.sh}}const dw={color:"#2196f3"},fw=(e,t,n)=>{const s=Mn(n);return new hw(e,t,s)};function Ml(e){const t={value:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function Cu(e){const t=Ml(e);return e.R!==void 0&&(t.color=e.R),t}function mw(e){const t=Ml(e);return e.vt!==void 0&&(t.lineColor=e.vt),e.ah!==void 0&&(t.topColor=e.ah),e.oh!==void 0&&(t.bottomColor=e.oh),t}function pw(e){const t=Ml(e);return e._h!==void 0&&(t.topLineColor=e._h),e.uh!==void 0&&(t.bottomLineColor=e.uh),e.dh!==void 0&&(t.topFillColor1=e.dh),e.fh!==void 0&&(t.topFillColor2=e.fh),e.ph!==void 0&&(t.bottomFillColor1=e.ph),e.mh!==void 0&&(t.bottomFillColor2=e.mh),t}function im(e){const t={open:e.Wt[0],high:e.Wt[1],low:e.Wt[2],close:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function gw(e){const t=im(e);return e.R!==void 0&&(t.color=e.R),t}function yw(e){const t=im(e),{R:n,Ht:s,hh:i}=e;return n!==void 0&&(t.color=n),s!==void 0&&(t.borderColor=s),i!==void 0&&(t.wickColor=i),t}function Sr(e){return{Area:mw,Line:Cu,Baseline:pw,Histogram:Cu,Bar:gw,Candlestick:yw,Custom:bw}[e]}function bw(e){const t=e.Qr;return{...e.ue,time:t}}const vw={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1,doNotSnapToHiddenSeriesIndices:!1},xw={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},ww={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:Wf,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Ho={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1,tickMarkDensity:2.5},Sw={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:"background"};function ku(){return{addDefaultPane:!0,hoveredSeriesOnTop:!0,width:0,height:0,autoSize:!1,layout:ww,crosshair:vw,grid:xw,overlayPriceScales:{...Ho},leftPriceScale:{...Ho,visible:!1},rightPriceScale:{...Ho,visible:!0},defaultVisiblePriceScaleId:"right",timeScale:Sw,localization:{locale:Vs?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class rm{constructor(t,n,s){this.hv=t,this.Ug=n,this.$g=s??0}applyOptions(t){this.hv.Qt().Dd(this.Ug,t,this.$g)}options(){return this.Ki().N()}width(){return Qr(this.Ug)?this.hv.DM(this.Ug):0}setVisibleRange(t){this.setAutoScale(!1),this.Ki().Go(new ke(t.from,t.to))}getVisibleRange(){let t,n,s=this.Ki().ar();if(s===null)return null;if(this.Ki().ho()){const i=this.Ki().S_(),r=Zf(i);s=Is(s,this.Ki().lo()),t=Number((Math.round(s.Je()/i)*i).toFixed(r)),n=Number((Math.round(s.Qe()/i)*i).toFixed(r))}else t=s.Je(),n=s.Qe();return{from:t,to:n}}setAutoScale(t){this.applyOptions({autoScale:t})}Ki(){return K(this.hv.Qt().Id(this.Ug,this.$g)).Ft}}class Cw{constructor(t,n,s,i){this.hv=t,this.yt=s,this.jg=n,this.qg=i}getHeight(){return this.yt.$t()}setHeight(t){const n=this.hv.Qt(),s=n._f(this.yt);n.Ld(s,t)}getStretchFactor(){return this.yt.F_()}setStretchFactor(t){this.yt.W_(t),this.hv.Qt().ka()}paneIndex(){return this.hv.Qt()._f(this.yt)}moveTo(t){const n=this.paneIndex();n!==t&&(pe(t>=0&&t<this.hv.lv().length,"Invalid pane index"),this.hv.Qt().Od(n,t))}getSeries(){return this.yt.Y_().map(t=>this.jg(t))??[]}getHTMLElement(){const t=this.hv.lv();return t&&t.length!==0&&t[this.paneIndex()]?t[this.paneIndex()].fv():null}attachPrimitive(t){this.yt.ol(t),t.attached&&t.attached({chart:this.qg,requestUpdate:()=>this.yt.Qt().ka()})}detachPrimitive(t){this.yt._l(t)}priceScale(t){if(this.yt.O_(t)===null)throw new Error(`Cannot find price scale with id: ${t}`);return new rm(this.hv,t,this.paneIndex())}setPreserveEmptyPane(t){this.yt.j_(t)}preserveEmptyPane(){return this.yt.q_()}addCustomSeries(t,n={},s=0){return this.qg.addCustomSeries(t,n,s)}addSeries(t,n={}){return this.qg.addSeries(t,n,this.paneIndex())}}const kw={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Mu{constructor(t){this._r=t}applyOptions(t){this._r.vr(t)}options(){return this._r.N()}Yg(){return this._r}}class Mw{constructor(t,n,s,i,r,o){this.Kg=new Zt,this.ae=t,this.Gg=n,this.Zg=s,this.Pu=r,this.qg=i,this.Xg=o}m(){this.Kg.m()}priceFormatter(){return this.ae.sl()}priceToCoordinate(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}coordinateToPrice(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Tn(t,n.Wt)}barsInLogicalRange(t){if(t===null)return null;const n=new zs(new Si(t.from,t.to)).Uu(),s=this.ae.Un();if(s.Zi())return null;const i=s.Hn(n.Na(),1),r=s.Hn(n.bi(),-1),o=K(s.Rh()),l=K(s.Qn());if(i!==null&&r!==null&&i.$n>r.$n)return{barsBefore:t.from-o,barsAfter:l-t.to};const c={barsBefore:i===null||i.$n===o?t.from-o:i.$n-o,barsAfter:r===null||r.$n===l?l-t.to:l-r.$n};return i!==null&&r!==null&&(c.from=i.Qr,c.to=r.Qr),c}setData(t){this.Pu,this.ae.bh(),this.Gg.Jg(this.ae,t),this.Qg("full")}update(t,n=!1){this.ae.bh(),this.Gg.tb(this.ae,t,n),this.Qg("update")}pop(t=1){const n=this.Gg.ib(this.ae,t);n.length!==0&&this.Qg("update");const s=Sr(this.seriesType());return n.map(i=>s(i))}dataByIndex(t,n){const s=this.ae.Un().Hn(t,n);return s===null?null:Sr(this.seriesType())(s)}data(){const t=Sr(this.seriesType());return this.ae.Un().Bh().map(n=>t(n))}subscribeDataChanged(t){this.Kg.i(t)}unsubscribeDataChanged(t){this.Kg._(t)}applyOptions(t){this.ae.vr(t)}options(){return an(this.ae.N())}priceScale(){return this.Zg.priceScale(this.ae.Ft().pl(),this.getPane().paneIndex())}createPriceLine(t){const n=$e(an(kw),t),s=this.ae.Ea(n);return new Mu(s)}removePriceLine(t){this.ae.Aa(t.Yg())}priceLines(){return this.ae.La().map(t=>new Mu(t))}seriesType(){return this.ae.bh()}lastValueData(t){const n=this.ae.Ae(t);return n.Le?{noData:!0}:{noData:!1,price:n.Mt,color:n.R}}attachPrimitive(t){this.ae.ol(t),t.attached&&t.attached({chart:this.qg,series:this,requestUpdate:()=>this.ae.Qt().ka(),horzScaleBehavior:this.Pu})}detachPrimitive(t){this.ae._l(t),t.detached&&t.detached(),this.ae.Qt().ka()}getPane(){const t=this.ae,n=K(this.ae.Qt().Ks(t));return this.Xg(n)}moveToPane(t){this.ae.Qt().rf(this.ae,t)}seriesOrder(){const t=this.ae.Qt().Ks(this.ae);return t===null?-1:t.Y_().indexOf(this.ae)}setSeriesOrder(t){const n=this.ae.Qt().Ks(this.ae);n!==null&&n.vu(this.ae,t)}Qg(t){this.Kg.v()&&this.Kg.p(t)}}class Ew{constructor(t,n,s){this.nb=new Zt,this.Qu=new Zt,this.Nw=new Zt,this.sn=t,this.ia=t.Et(),this.vM=n,this.ia.Zc().i(this.sb.bind(this)),this.ia.Xc().i(this.eb.bind(this)),this.vM.qw().i(this.rb.bind(this)),this.Pu=s}m(){this.ia.Zc().u(this),this.ia.Xc().u(this),this.vM.qw().u(this),this.nb.m(),this.Qu.m(),this.Nw.m()}scrollPosition(){return this.ia.Oc()}scrollToPosition(t,n){n?this.ia.Yc(t,1e3):this.sn.gs(t)}scrollToRealTime(){this.ia.qc()}getVisibleRange(){const t=this.ia.xc();return t===null?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const n={from:this.Pu.convertHorzItemToInternal(t.from),to:this.Pu.convertHorzItemToInternal(t.to)},s=this.ia.kc(n);this.sn.sf(s)}getVisibleLogicalRange(){const t=this.ia.Sc();return t===null?null:{from:t.Na(),to:t.bi()}}setVisibleLogicalRange(t){pe(t.from<=t.to,"The from index cannot be after the to index."),this.sn.sf(t)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.td()}logicalToCoordinate(t){const n=this.sn.Et();return n.Zi()?null:n.jt(t)}coordinateToLogical(t){return this.ia.Zi()?null:this.ia.Vc(t)}timeToIndex(t,n){const s=this.Pu.convertHorzItemToInternal(t);return this.ia.Mc(s,n)}timeToCoordinate(t){const n=this.timeToIndex(t,!1);return n===null?null:this.ia.jt(n)}coordinateToTime(t){const n=this.sn.Et(),s=n.Vc(t),i=n.en(s);return i===null?null:i.originalTime}width(){return this.vM.pv().width}height(){return this.vM.pv().height}subscribeVisibleTimeRangeChange(t){this.nb.i(t)}unsubscribeVisibleTimeRangeChange(t){this.nb._(t)}subscribeVisibleLogicalRangeChange(t){this.Qu.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.Qu._(t)}subscribeSizeChange(t){this.Nw.i(t)}unsubscribeSizeChange(t){this.Nw._(t)}applyOptions(t){this.ia.vr(t)}options(){return{...an(this.ia.N()),barSpacing:this.ia.ml()}}sb(){this.nb.v()&&this.nb.p(this.getVisibleRange())}eb(){this.Qu.v()&&this.Qu.p(this.getVisibleLogicalRange())}rb(t){this.Nw.p(t.width,t.height)}}function Eu(e){return function(t){if(or(t.handleScale)){const s=t.handleScale;t.handleScale={axisDoubleClickReset:{time:s,price:s},axisPressedMouseMove:{time:s,price:s},mouseWheel:s,pinch:s}}else if(t.handleScale!==void 0){const{axisPressedMouseMove:s,axisDoubleClickReset:i}=t.handleScale;or(s)&&(t.handleScale.axisPressedMouseMove={time:s,price:s}),or(i)&&(t.handleScale.axisDoubleClickReset={time:i,price:i})}const n=t.handleScroll;or(n)&&(t.handleScroll={horzTouchDrag:n,vertTouchDrag:n,mouseWheel:n,pressedMouseMove:n})}(e),e}class Tw{constructor(t,n,s){this.hb=new Map,this.ab=new Map,this.lb=new Zt,this.ob=new Zt,this._b=new Zt,this.dd=new WeakMap,this.ub=new tw(n);const i=s===void 0?an(ku()):$e(an(ku()),Eu(s));this.cb=n,this.hv=new qx(t,i,n),this.hv.mw().i(o=>{this.lb.v()&&this.lb.p(this.fb(o()))},this),this.hv.ww().i(o=>{this.ob.v()&&this.ob.p(this.fb(o()))},this),this.hv.Bd().i(o=>{this._b.v()&&this._b.p(this.fb(o()))},this);const r=this.hv.Qt();this.pb=new Ew(r,this.hv.bM(),this.cb)}remove(){this.hv.mw().u(this),this.hv.ww().u(this),this.hv.Bd().u(this),this.pb.m(),this.hv.m(),this.hb.clear(),this.ab.clear(),this.lb.m(),this.ob.m(),this._b.m(),this.ub.m()}resize(t,n,s){this.autoSizeActive()||this.hv.wM(t,n,s)}addCustomSeries(t,n={},s=0){const i=(r=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...dw,...r.defaultOptions()},mb:fw,wb:r}))(Mn(t));return this.Mb(i,n,s)}addSeries(t,n={},s=0){return this.Mb(t,n,s)}removeSeries(t){const n=Re(this.hb.get(t)),s=this.ub.if(n);this.hv.Qt().if(n),this.gb(s),this.hb.delete(t),this.ab.delete(n)}Jg(t,n){this.gb(this.ub.og(t,n))}tb(t,n,s){this.gb(this.ub.pg(t,n,s))}ib(t,n){const[s,i]=this.ub.wg(t,n);return s.length!==0&&this.gb(i),s}subscribeClick(t){this.lb.i(t)}unsubscribeClick(t){this.lb._(t)}subscribeCrosshairMove(t){this._b.i(t)}unsubscribeCrosshairMove(t){this._b._(t)}subscribeDblClick(t){this.ob.i(t)}unsubscribeDblClick(t){this.ob._(t)}priceScale(t,n=0){return new rm(this.hv,t,n)}timeScale(){return this.pb}applyOptions(t){this.hv.vr(Eu(t))}options(){return this.hv.N()}takeScreenshot(t=!1,n=!1){let s,i;try{n||(s=this.hv.Qt().N().crosshair.mode,this.hv.vr({crosshair:{mode:2}})),i=this.hv.TM(t)}finally{n||s===void 0||this.hv.Qt().vr({crosshair:{mode:s}})}return i}addPane(t=!1){const n=this.hv.Qt().uf();return n.j_(t),this.bb(n)}removePane(t){this.hv.Qt().Ad(t)}swapPanes(t,n){this.hv.Qt().zd(t,n)}autoSizeActive(){return this.hv.CM()}chartElement(){return this.hv.Mv()}panes(){return this.hv.Qt().Gn().map(t=>this.bb(t))}paneSize(t=0){const n=this.hv.AM(t);return{height:n.height,width:n.width}}setCrosshairPosition(t,n,s){const i=this.hb.get(s);if(i===void 0)return;const r=this.hv.Qt().Ks(i);r!==null&&this.hv.Qt().Gd(t,n,r)}clearCrosshairPosition(){this.hv.Qt().Zd(!0)}horzBehaviour(){return this.cb}Mb(t,n={},s=0){pe(t.mb!==void 0),function(c){if(c===void 0||c.type==="custom")return;const h=c;h.minMove!==void 0&&h.precision===void 0&&(h.precision=Zf(h.minMove))}(n.priceFormat),t.type==="Candlestick"&&function(c){c.borderColor!==void 0&&(c.borderUpColor=c.borderColor,c.borderDownColor=c.borderColor),c.wickColor!==void 0&&(c.wickUpColor=c.wickColor,c.wickDownColor=c.wickColor)}(n);const i=$e(an(Ff),an(t.defaultOptions),n),r=t.mb,o=new Kr(this.hv.Qt(),t.type,i,r,t.wb);this.hv.Qt().Qd(o,s);const l=new Mw(o,this,this,this,this.cb,c=>this.bb(c));return this.hb.set(l,o),this.ab.set(o,l),l}gb(t){const n=this.hv.Qt();for(const s of t.Y_.keys())s.Ia();n.Xd(t.Et.Dc,t.Et.Sg,t.Et.xg),t.Y_.forEach((s,i)=>i.ht(s.ue,s.bg)),n.Et().dc(),n.Lc()}Sb(t){return Re(this.ab.get(t))}xb(t){return t!==void 0&&this.ab.has(t)?this.Sb(t):void 0}fb(t){const n=new Map;t.QM.forEach((r,o)=>{const l=o.bh(),c=Sr(l)(r);if(l!=="Custom")pe(Yx(c));else{const h=o.cl();pe(!h||h(c)===!1)}n.set(this.Sb(o),c)});const s=this.xb(t.jM),i=t.YM===void 0?void 0:{type:t.YM.ds,sourceKind:t.YM.KM,objectKind:t.YM.GM,series:this.xb(t.YM.Y_),objectId:t.YM.ZM,paneIndex:t.YM.XM};return{time:t.Qr,logical:t.$n,point:t.JM,paneIndex:t.XM,hoveredInfo:i,hoveredSeries:s,hoveredObjectId:t.qM,seriesData:n,sourceEvent:t.tg}}bb(t){let n=this.dd.get(t);return n||(n=new Cw(this.hv,s=>this.Sb(s),t,this),this.dd.set(t,n)),n}}function Aw(e){if(Bi(e)){const t=document.getElementById(e);return pe(t!==null,`Cannot find element in DOM with id=${e}`),t}return e}function Rw(e,t,n){const s=Aw(e),i=new Tw(s,t,n);return t.setOptions(i.options()),i}function Pw(e,t){return Rw(e,new cu,cu.Tf(t))}function li(e,t,n,s){return Math.hypot(n-e,s-t)}function om(e,t,n,s,i,r,o,l=0){if(t.length===0||s.from>=t.length||s.to<=0)return;const{context:c,horizontalPixelRatio:h,verticalPixelRatio:a}=e,u=t[s.from];let f=r(e,u),p=u;if(s.to-s.from<2){const g=i/2;c.beginPath();const d={_t:u._t-g,ut:u.ut},w={_t:u._t+g,ut:u.ut};c.moveTo(d._t*h,d.ut*a),c.lineTo(w._t*h,w.ut*a),o(e,f,d,w)}else{const g=l>0;let d=0;const w=(x,k)=>{if(o(e,f,p,k),c.beginPath(),f=x,p=k,g){const S=d%l;c.lineDashOffset=S,d=S}};let C=p;c.beginPath(),c.moveTo(u._t*h,u.ut*a);for(let x=s.from+1;x<s.to;++x){C=t[x];const k=C._t*h,S=C.ut*a,T=r(e,C);switch(n){case 0:if(c.lineTo(k,S),g){const P=t[x-1],I=P._t*h,L=P.ut*a;d+=li(I,L,k,S)}break;case 1:{const P=t[x-1],I=P.ut*a;c.lineTo(k,I),g&&(d+=Math.abs(C._t-P._t)*h),T!==f&&(w(T,C),c.lineTo(k,I)),c.lineTo(k,S),g&&(d+=Math.abs(C.ut-P.ut)*a);break}case 2:{const[P,I]=El(t,x-1,x),L=P._t*h,O=P.ut*a,H=I._t*h,U=I.ut*a;if(c.bezierCurveTo(L,O,H,U,k,S),g){const q=t[x-1],X=q._t*h,j=q.ut*a,D=li(X,j,k,S),V=li(X,j,L,O)+li(L,O,H,U)+li(H,U,k,S);d+=(D+V)/2}break}}n!==1&&T!==f&&(w(T,C),c.moveTo(k,S))}(p!==C||p===C&&n===1)&&o(e,f,p,C),g&&(c.lineDashOffset=0)}}const Tu=6;function qo(e,t){return{_t:e._t-t._t,ut:e.ut-t.ut}}function Au(e,t){return{_t:e._t/t,ut:e.ut/t}}function El(e,t,n){const s=Math.max(0,t-1),i=Math.min(e.length-1,n+1);var r,o;return[(r=e[t],o=Au(qo(e[n],e[s]),Tu),{_t:r._t+o._t,ut:r.ut+o.ut}),qo(e[n],Au(qo(e[i],e[t]),Tu))]}function _w(e,t){const n=e.context;n.strokeStyle=t,n.stroke()}class $w extends Nn{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:s,Cb:i,yb:r,ct:o,Gt:l,Pb:c}=this.rt;if(s===null)return;const h=t.context;h.lineCap="butt",h.lineWidth=o*t.verticalPixelRatio;const a=_n(h,l);h.lineJoin="round";const u=this.kb.bind(this),f=function(p){return p.reduce((g,d)=>g+d,0)}(a);r!==void 0&&om(t,n,r,s,i,u,_w,f),c&&function(p,g,d,w,C){if(w.to-w.from<=0)return;const{horizontalPixelRatio:x,verticalPixelRatio:k,context:S}=p;let T=null;const P=Math.max(1,Math.floor(x))%2/2,I=d*k+P;for(let L=w.to-1;L>=w.from;--L){const O=g[L];if(O){const H=C(p,O);H!==T&&(T!==null&&S.fill(),S.beginPath(),S.fillStyle=H,T=H);const U=Math.round(O._t*x)+P,q=O.ut*k;S.moveTo(U,q),S.arc(U,q,I,0,2*Math.PI)}}S.fill()}(t,n,c,s,u)}}class am extends $w{kb(t,n){return n.vt}}function Ru(e,t,n,s,i){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function Nw(e,t,n,s,i){if(n===2){const[r,o]=El(s,i-1,i);return[Math.min(e._t,t._t,r._t,o._t),Math.max(e._t,t._t,r._t,o._t)]}return[Math.min(e._t,t._t),Math.max(e._t,t._t)]}function Iw(e,t,n,s,i,r,o,l){switch(i){case 1:{const c=mi(e,t,n._t,n.ut,s._t,n.ut),h=mi(e,t,s._t,n.ut,s._t,s.ut),a=Math.min(c,h);return a<=l?a:null}case 2:{const[c,h]=El(r,o-1,o),a=function(u,f,p){let g=Number.POSITIVE_INFINITY,d=p[0];for(let w=1;w<=12;w++){const C=w/12,x={_t:Ru(p[0]._t,p[1]._t,p[2]._t,p[3]._t,C),ut:Ru(p[0].ut,p[1].ut,p[2].ut,p[3].ut,C)};g=Math.min(g,mi(u,f,d._t,d.ut,x._t,x.ut)),d=x}return g}(e,t,[n,c,h,s]);return a<=l?a:null}default:{const c=mi(e,t,n._t,n.ut,s._t,s.ut);return c<=l?c:null}}}class Dw extends kl{constructor(t,n){super(t,n,!0)}Og(t,n,s){n.Ic(this.kg,Ni(this.Tg)),t.Jo(this.kg,s,Ni(this.Tg))}Tb(t,n){return{wt:t,Mt:n,_t:NaN,ut:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>{let s;if((n.Gr??1)>1){const i=n.Wt[1],r=n.Wt[2],o=n.Wt[3];s=Math.abs(i-o)>Math.abs(r-o)?i:r}else s=n.Wt[3];return this.Rb(n.$n,s,t)})}}class lm extends Dw{Bg(t,n){const s=this.ae.N();return function(i,r,o,l,c,h,a,u=0,f=0){if(r===null||r.from>=r.to||i.length===0)return null;const p=Math.max(h/2,a??0)+f;let g=Number.POSITIVE_INFINITY;if(a!==void 0){const S=a+f,T=ka(i,o-S,r.from,r.to),P=Ma(i,o+S,T,r.to);for(let I=T;I<P;I++){const L=i[I];if(!Su(o,L._t,L._t,a+f))continue;const O=Math.hypot(o-L._t,l-L.ut);O<=a+f&&(g=Math.min(g,O))}}if(r.to-r.from<2){const S=i[r.from],T=Math.max(u/2,p),P=mi(o,l,S._t-T,S.ut,S._t+T,S.ut);return P<=p&&(g=Math.min(g,P)),Number.isFinite(g)?wr(g,2,"series-point"):null}let d=Number.POSITIVE_INFINITY;const w=ka(i,o-p,r.from,r.to),C=Ma(i,o+p,w,r.to),x=Math.max(r.from+1,w),k=Math.min(r.to,C+1);for(let S=x;S<k;S++){const T=i[S-1],P=i[S],[I,L]=Nw(T,P,c,i,S);if(!Su(o,I,L,p))continue;const O=Iw(o,l,T,P,c,i,S,p);O!==null&&(d=Math.min(d,O))}return Number.isFinite(g)?wr(g,2,"series-point"):Number.isFinite(d)?wr(d,1,"series-line"):null}(this.kg,this.Tg,t,n,s.lineType,s.lineVisible?s.lineWidth:1,s.pointMarkersVisible?s.pointMarkersRadius||s.lineWidth/2+2:void 0,this.le.Et().ml(),s.hitTestTolerance)}}class Lw extends lm{constructor(){super(...arguments),this.Vg=new am}Rb(t,n,s){return{...this.Tb(t,n),...s.Sh(t)}}Ng(){const t=this.ae.N(),n={ot:this.kg,Gt:t.lineStyle,yb:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Tg,Cb:this.le.Et().ml()};this.Vg.ht(n)}}const zw={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Lw(e,t)};function Fw(e,t,n,s,i){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;r.lineTo(i._t*o,e*l),r.lineTo(s._t*o,e*l),r.closePath(),r.fillStyle=n,r.fill()}class Bw extends Nn{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:s,Cb:i,ct:r,Gt:o,yb:l}=this.rt,c=this.rt.Lb??(this.rt.zb?0:t.mediaSize.height);if(s===null)return;const h=t.context;h.lineCap="butt",h.lineJoin="round",h.lineWidth=r,_n(h,o),h.lineWidth=1,om(t,n,l,s,i,this.Ob.bind(this),Fw.bind(null,c))}}class Ww{Nb(t,n){const s=this.Fb,{Wb:i,Hb:r,Ub:o,$b:l,Lb:c,jb:h,qb:a}=n;if(this.Yb===void 0||s===void 0||s.Wb!==i||s.Hb!==r||s.Ub!==o||s.$b!==l||s.Lb!==c||s.jb!==h||s.qb!==a){const{verticalPixelRatio:u}=t,f=c||h>0?u:1,p=h*f,g=a===t.bitmapSize.height?a:a*f,d=(c??0)*f,w=t.context.createLinearGradient(0,p,0,g);if(w.addColorStop(0,i),c!=null){const C=Ls((d-p)/(g-p),0,1);w.addColorStop(C,r),w.addColorStop(C,o)}w.addColorStop(1,l),this.Yb=w,this.Fb=n}return this.Yb}}class jw{constructor(t,n,s,i){this.Zb=t,this.Xb=n,this.Jb=s,this.Qb=i}st(t,n,s){this.Zb.st(t,n,s),!this.Jb()||n&&this.Qb()||this.Xb.st(t,n,s)}}class Vw{constructor(t,n){this.Xb=t,this.tS=n}Tt(){return this.tS()?this.Xb:null}}class Ow extends Bw{constructor(){super(...arguments),this.Kb=new Ww}Ob(t,n){var s;return this.Kb.Nb(t,{Wb:n.ah,Hb:"",Ub:"",$b:n.oh,jb:((s=this.rt)==null?void 0:s.jb)??0,qb:t.bitmapSize.height})}}class Uw extends lm{constructor(t,n){super(t,n),this.lS=new Ow,this.Xb=new am,this.sS=new Vw(this.Xb,()=>this.Jb()),this.eS=[this],this.rS=[this.sS],this.hS={Za:this.eS,qa:this.rS},this.Vg=new jw(this.lS,this.Xb,()=>this.Jb(),()=>this.le.N().hoveredSeriesOnTop)}Ga(){return this.hS}Rb(t,n,s){return{...this.Tb(t,n),...s.Sh(t)}}Ng(){const t=this.ae.N();if(this.Tg===null||this.kg.length===0)return;let n;if(t.relativeGradient){n=this.kg[this.Tg.from].ut;for(let s=this.Tg.from;s<this.Tg.to;s++){const i=this.kg[s];i.ut<n&&(n=i.ut)}}this.lS.ht({yb:t.lineType,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,Lb:null,jb:n,zb:t.invertFilledArea,lt:this.Tg,Cb:this.le.Et().ml()}),this.Xb.ht({yb:t.lineVisible?t.lineType:void 0,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,lt:this.Tg,Cb:this.le.Et().ml(),Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}Jb(){return this.ae.It()&&this.Tg!==null&&this.aS()}aS(){const t=this.ae.N();return t.lineVisible||t.pointMarkersVisible}}const Hw={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Uw(e,t)};class qw extends kl{constructor(t,n){super(t,n,!1)}Bg(t,n){return sm(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(s,i)=>{i[0]=s.n_,i[1]=s.s_})}Og(t,n,s){n.Ic(this.kg,Ni(this.Tg)),t.t_(this.kg,s,Ni(this.Tg))}fS(t,n,s){return{wt:t,jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3],_t:NaN,i_:NaN,n_:NaN,s_:NaN,e_:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>this.Rb(n.$n,n,t))}}class Gw extends Nn{constructor(){super(...arguments),this.qt=null,this.oS=0}ht(t){this.qt=t}et(t){if(this.qt===null||this.qt.Un.length===0||this.qt.lt===null)return;const{horizontalPixelRatio:n}=t;this.oS=function(r,o){if(r>=2.5&&r<=4)return Math.floor(3*o);const l=1-.2*Math.atan(Math.max(4,r)-4)/(.5*Math.PI),c=Math.floor(r*l*o),h=Math.floor(r*o),a=Math.min(c,h);return Math.max(Math.floor(o),a)}(this.qt.ml,n),this.oS>=2&&Math.floor(n)%2!=this.oS%2&&this.oS--;const s=this.qt.Un;this.qt.pS&&this.vS(t,s,this.qt.lt),this.qt.gi&&this.Vm(t,s,this.qt.lt);const i=this.mS(n);(!this.qt.gi||this.oS>2*i)&&this.wS(t,s,this.qt.lt)}vS(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="",c=Math.min(Math.floor(r),Math.floor(this.qt.ml*r));c=Math.max(Math.floor(r),Math.min(c,this.oS));const h=Math.floor(.5*c);let a=null;for(let u=s.from;u<s.to;u++){const f=n[u];f.rh!==l&&(i.fillStyle=f.rh,l=f.rh);const p=Math.round(Math.min(f.i_,f.e_)*o),g=Math.round(Math.max(f.i_,f.e_)*o),d=Math.round(f.n_*o),w=Math.round(f.s_*o);let C=Math.round(r*f._t)-h;const x=C+c-1;a!==null&&(C=Math.max(a+1,C),C=Math.min(C,x));const k=x-C+1;i.fillRect(C,d,k,p-d),i.fillRect(C,g+1,k,w-g),a=x}}mS(t){let n=Math.floor(1*t);this.oS<=2*n&&(n=Math.floor(.5*(this.oS-1)));const s=Math.max(Math.floor(t),n);return this.oS<=2*s?Math.max(Math.floor(t),Math.floor(1*t)):s}Vm(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const c=this.mS(r);let h=null;for(let a=s.from;a<s.to;a++){const u=n[a];u.eh!==l&&(i.fillStyle=u.eh,l=u.eh);let f=Math.round(u._t*r)-Math.floor(.5*this.oS);const p=f+this.oS-1,g=Math.round(Math.min(u.i_,u.e_)*o),d=Math.round(Math.max(u.i_,u.e_)*o);if(h!==null&&(f=Math.max(h+1,f),f=Math.min(f,p)),this.qt.ml*r>2*c)$v(i,f,g,p-f+1,d-g+1,c);else{const w=p-f+1;i.fillRect(f,g,w,d-g+1)}h=p}}wS(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const c=this.mS(r);for(let h=s.from;h<s.to;h++){const a=n[h];let u=Math.round(Math.min(a.i_,a.e_)*o),f=Math.round(Math.max(a.i_,a.e_)*o),p=Math.round(a._t*r)-Math.floor(.5*this.oS),g=p+this.oS-1;if(a.sh!==l){const d=a.sh;i.fillStyle=d,l=d}this.qt.gi&&(p+=c,u+=c,g-=c,f-=c),u>f||i.fillRect(p,u,g-p+1,f-u+1)}}}class Yw extends qw{constructor(){super(...arguments),this.Vg=new Gw}Rb(t,n,s){return{...this.fS(t,n,s),...s.Sh(t)}}Ng(){const t=this.ae.N();this.Vg.ht({Un:this.kg,ml:this.le.Et().ml(),pS:t.wickVisible,gi:t.borderVisible,lt:this.Tg})}}const Xw={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},mb:(e,t)=>new Yw(e,t)};({...Ff});const Qw=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},Br=(...e)=>{Qw()&&console.warn(...e)};function Jw(e,t,n){var o,l;const s=t.expression?((o=e.evaluateExpression)==null?void 0:o.call(e,t.expression,t.expressionUrl,n,t.expressionKey))??e.interpolateText(t.expression):e.interpolateText(t.text||"");if(t.className){const c=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const a=bl(t.className);if(a.size>0){const f=ht(a,e.containerWidth,"1rem");c.fontSize=f}const u=Gs(t.className);u.size>0&&(c.display=ht(u,e.containerWidth,"block"))}const h=e.getCommonProps(n,c,t);return E("p",{key:n,className:t.className,...h},s)}const i={color:e.cfg.colors.text};t.fontSize!==void 0&&(i.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(i.fontWeight=t.fontWeight),t.color!==void 0&&(i.color=t.color),t.textAlign!==void 0&&(i.textAlign=t.textAlign);const r=e.getCommonProps(n,i,t);return E("p",{key:n,...r},s)}function Kw(e){return e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<iframe[\s\S]*?<\/iframe>/gi,"").replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"")}function Zw(e,t,n){const s=String(e.apiUrl||"").replace(/\/$/,""),i=e.interpolateText(t.text||t.html||"").replace(/(src|href)=("|')\/(?!\/)/g,s?`$1=$2${s}/`:"$1=$2/"),r=e.getCommonProps(n,{color:e.cfg.colors.text},t);return E("div",{key:n,className:t.className,...r,dangerouslySetInnerHTML:{__html:Kw(i)}})}function t1(e,t,n){var l,c,h,a,u;const s=()=>{t.onClick?e.handleButtonClick(t.onClick,{onSuccess:t.onSuccess,onError:t.onError},{optimistic:t.optimistic,feedback:t.feedback}):t.href&&(t.href.startsWith("http")||e.previewMode?window.open(t.href,"_blank","noopener,noreferrer"):window.location.href=t.href)},i=()=>{var f;if(!e.interactionDisabled){if((f=t.confirmation)!=null&&f.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:14}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{s()}});return}s()}};if(t.className){const f=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const g=Gs(t.className);g.size>0&&(f.display=ht(g,e.containerWidth,"inline"));const d=bl(t.className);if(d.size>0){const w=ht(d,e.containerWidth,"1rem");f.fontSize=w}}t.icon&&(f.display="inline-flex",f.alignItems="center",f.gap=6);const p=e.getCommonProps(n,f,t);return E("a",{key:n,className:t.className,...p,onClick:e.interactionDisabled?void 0:i,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(c=t.href)!=null&&c.startsWith("http")?"_blank":void 0,rel:(h=t.href)!=null&&h.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}const r={cursor:"pointer",textDecoration:"none",transition:"all 0.2s",display:"inline-flex",alignItems:"center",gap:6},o=e.getCommonProps(n,r,t);return E("a",{key:n,...o,onClick:e.interactionDisabled?void 0:i,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(a=t.href)!=null&&a.startsWith("http")?"_blank":void 0,rel:(u=t.href)!=null&&u.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}function e1(e,t,n){var g,d,w,C,x;let s=!1;if(t.activeWhen){if(t.activeWhen===e.currentSceneId)s=!0;else if(typeof t.activeWhen=="string"){const k=t.activeWhen.split("=",2);k.length===2&&(s=String(((g=e.sceneData)==null?void 0:g[k[0]])??"")===k[1])}}const i=s?{onClick:t.activeOnClick||t.onClick,onSuccess:t.activeOnSuccess||t.onSuccess,onError:t.activeOnError||t.onError,icon:t.activeIcon||t.icon,text:t.activeText||t.text,label:t.activeText||t.label}:{onClick:t.onClick,onSuccess:t.onSuccess,onError:t.onError,icon:t.icon,text:t.text,label:t.label},r=t.disabled?((d=e.evaluateCondition)==null?void 0:d.call(e,t.disabled))??!1:!1,o=k=>{const S=()=>e.handleButtonClick(i.onClick||"",{onSuccess:i.onSuccess,onError:i.onError},{optimistic:t.optimistic,feedback:t.feedback,refetchScope:t.refetchScope,mergeResponse:t.mergeResponse,anchorElement:k==null?void 0:k.currentTarget});(e.withLoading?e.withLoading(n,S):S()).catch(P=>{var L,O;const I=((L=t.onError)==null?void 0:L.message)||(P==null?void 0:P.message)||"An error occurred";(O=e.showToast)==null||O.call(e,I,"error")})},l=k=>{var S;if((S=t.confirmation)!=null&&S.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:16}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{o(k)}});return}o(k)},c=(w=e.buttonLoading)==null?void 0:w[n];if(t.className){let k=((C=e.parseClassNameResponsive)==null?void 0:C.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const U=Gs(t.className);U.size>0&&(k.display=ht(U,e.containerWidth,"inline-flex"));const q=bl(t.className);q.size>0&&(k.fontSize=ht(q,e.containerWidth,"1rem"))}let S=t.className;if(s&&t.activeClass){const U=((x=e.parseClassNameResponsive)==null?void 0:x.call(e,t.activeClass,n))??e.parseClassName(t.activeClass);k={...k,...U},S=`${t.className} ${t.activeClass}`}const T={display:"inline-flex",alignItems:"center",justifyContent:k.textAlign==="left"?"flex-start":k.textAlign==="right"?"flex-end":"center",gap:"6px",...k,...t.color&&{color:t.color},...t.background&&{background:t.background},...t.borderRadius!==void 0&&{borderRadius:typeof t.borderRadius=="number"?`${t.borderRadius}px`:t.borderRadius},...t.borderColor&&{borderColor:t.borderColor},...c&&{opacity:.6,pointerEvents:"none"}},P={},I=(t.className||"").split(/\s+/).filter(Boolean);for(const U of I)if(U.startsWith("hover:")){const q=U.replace("hover:","");if(q.startsWith("bg-")||q.startsWith("text-")||q.startsWith("border-")){const X=e.parseClassName(q);Object.assign(P,X)}}const L=e.getCommonProps(n,T,t),O=[];i.icon&&!c&&O.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...i.text?{marginRight:"6px"}:{}}},e.renderIcon(i.icon,t.iconSize||16))),c&&O.unshift(E("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),Array.isArray(t.children)&&t.children.length>0?t.children.forEach((U,q)=>{O.push(e.renderComponent(U,q,n))}):O.push(i.label||i.text||(i.icon?"":"Button"));const H={};return Object.keys(P).length>0&&(H.onMouseEnter=U=>{P.backgroundColor&&(U.currentTarget.style.backgroundColor=P.backgroundColor),P.color&&(U.currentTarget.style.color=P.color),P.borderColor&&(U.currentTarget.style.borderColor=P.borderColor)},H.onMouseLeave=U=>{P.backgroundColor&&(U.currentTarget.style.backgroundColor=T.backgroundColor||""),P.color&&(U.currentTarget.style.color=T.color||""),P.borderColor&&(U.currentTarget.style.borderColor=T.borderColor||"")}),E("button",{key:n,className:S,title:e.interpolateText(t.tooltip||t.ariaLabel||i.label||i.text||"Button"),...L,...H,onClick:e.interactionDisabled?void 0:l,disabled:c||r||void 0},...O)}const h=e.cfg.colors.primary,a=e.cfg.colors.accent,u={display:"inline-flex",alignItems:"center",gap:"6px",padding:"0.75rem 1.5rem",borderRadius:"0.75rem",fontWeight:600,transition:e.cfg.effects.transition,color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.text,background:s?e.cfg.colors.primary:`linear-gradient(to right, ${h}, ${a})`,boxShadow:s?"none":`0 10px 15px -3px ${h}40`,...c&&{opacity:.6,pointerEvents:"none"}},f=e.getCommonProps(n,u,t),p=[];return c&&p.push(E("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),i.icon&&!c&&p.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(i.icon,t.iconSize||16))),p.push(i.label||i.text||(i.icon?"":"Button")),E("button",{key:n,title:e.interpolateText(t.tooltip||t.ariaLabel||i.label||i.text||"Button"),...f,onClick:e.interactionDisabled?void 0:l,disabled:c||r||void 0},...p)}function n1(e,t,n){var h;const s=e.interpolateText(t.src||""),i=!s||s==="placeholder",r=e.imageErrors[n];if(t.skipEmpty&&i)return null;const o={border:`1px dashed ${e.cfg.colors.borderSubtle}`,display:"flex",alignItems:"center",justifyContent:"center",padding:10,height:"200px",borderRadius:"0.75rem"};if(i){const a=e.getCommonProps(n,o,t);return E("div",{key:n,...a},E("span",{style:{color:e.cfg.colors.textPlaceholder,fontSize:"0.875rem"}},"Image"))}if(r)return null;if(t.className){const a=((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className),u=e.getCommonProps(n,a,t),f={key:`${n}-${s}`,src:s,alt:t.alt||"",className:t.className,...u,onError:()=>e.setImageErrors(p=>({...p,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(f.onClick=()=>e.handleButtonClick(t.onClick)),E("img",f)}const l={width:t.w||t.width||"100%",height:t.h||t.height||"auto",objectFit:"cover",borderRadius:"0.75rem"};t.onClick&&(l.cursor="pointer");const c={key:`${n}-${s}`,src:s,alt:t.alt||"",...e.getCommonProps(n,l,t),onError:()=>e.setImageErrors(a=>({...a,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(c.onClick=()=>e.handleButtonClick(t.onClick)),E("img",c)}function s1(e,t,n){var r;if(t.className){const o=((r=e.parseClassNameResponsive)==null?void 0:r.call(e,t.className,n))??e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("input",{key:n,className:t.className,...l,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.value})),onKeyDown:t.onKeyDown?c=>{c.key==="Enter"&&e.handleButtonClick(t.onKeyDown)}:void 0})}const s={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},i=e.getCommonProps(n,s,t);if(t.label){const o=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...o},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("input",{...i,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:l=>e.setSceneData(c=>({...c,[t.name||""]:l.target.value}))}))}return E("input",{key:n,...i,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:o=>e.setSceneData(l=>({...l,[t.name||""]:o.target.value}))})}function i1(e,t,n){const s=t.value?e.interpolateText(String(t.value)):e.sceneData[t.name||""]??"";return E("input",{key:n,type:"hidden",name:t.name,value:s})}function r1(e,t,n){var o;const s=()=>{var l;return[t.placeholder&&E("option",{key:"__placeholder",value:""},t.placeholder),...((l=t.options)==null?void 0:l.map(c=>E("option",{key:c.value,value:c.value},c.label)))||[]]};if(t.className){const l=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className),c=e.getCommonProps(n,l,t);return E("select",{key:n,className:t.className,...c,name:t.name,value:e.sceneData[t.name||""]??"",onChange:h=>e.setSceneData(a=>({...a,[t.name||""]:h.target.value}))},...s())}const i={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,cursor:"pointer",appearance:"none"},r=e.getCommonProps(n,i,t);if(t.label){const l=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...l},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("select",{...r,name:t.name,value:e.sceneData[t.name||""]??"",onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.value}))},...s()))}return E("select",{key:n,...r,name:t.name,value:e.sceneData[t.name||""]??"",onChange:l=>e.setSceneData(c=>({...c,[t.name||""]:l.target.value}))},...s())}function o1(e,t,n){const s=t.className||"flex items-center gap-3 cursor-pointer text-white",i=e.parseClassName(s),r="w-5 h-5 rounded border-gray-600 bg-gray-800 accent-primary",o=e.parseClassName(r),l=e.getCommonProps(n,i,t);return E("label",{key:n,className:s,...l},E("input",{type:"checkbox",className:r,style:o,checked:e.sceneData[t.name||""]||!1,onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.checked}))}),E("span",{},t.label||""))}function a1(e,t,n){const s={green:{bg:"#065f4620",color:"#22c55e",border:"#22c55e40"},blue:{bg:"#1e40af20",color:"#3b82f6",border:"#3b82f640"},red:{bg:"#7f1d1d20",color:"#ef4444",border:"#ef444440"},yellow:{bg:"#71370220",color:"#eab308",border:"#eab30840"},purple:{bg:"#581c8720",color:"#a855f7",border:"#a855f740"},orange:{bg:"#7c2d1220",color:"#f97316",border:"#f9731640"},gray:{bg:"#37415120",color:"#9ca3af",border:"#9ca3af40"},cyan:{bg:"#0e727020",color:"#06b6d4",border:"#06b6d440"},pink:{bg:"#83184420",color:"#ec4899",border:"#ec489940"}};let r=t.colorScheme||"gray";if(t.colorBy&&typeof t.colorBy=="object"){const a=(e.interpolateText(t.text||t.label||"")||"").trim().toLowerCase();t.colorBy[a]&&(r=t.colorBy[a])}const o=s[r]||s.gray,l=t.variant||"subtle";let c={display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,letterSpacing:"0.025em",textTransform:"uppercase",whiteSpace:"nowrap"};l==="solid"?(c.backgroundColor=o.color,c.color="#fff"):l==="outline"?(c.backgroundColor="transparent",c.color=o.color,c.border=`1px solid ${o.border||o.color}`):(c.backgroundColor=o.bg,c.color=o.color,t.bordered&&(c.border=`1px solid ${o.border||o.color}`)),t.pill&&(c.borderRadius="9999px"),t.className&&(c={...c,...e.parseClassName(t.className)});const h=e.getCommonProps(n,c,t);return E("span",{key:n,...h},e.interpolateText(t.text||t.label||""))}function l1(e,t,n){const s={display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",borderRadius:"9999px",fontSize:"12px",fontWeight:500,backgroundColor:t.bg||e.cfg.colors.surfaceHover,color:t.color||e.cfg.colors.textSecondary,...t.className?e.parseClassName(t.className):{}},i=e.getCommonProps(n,s,t);return E("span",{key:n,...i},e.interpolateText(t.text||t.label||""))}function c1(e,t,n){const i={sm:32,md:40,lg:48,xl:64}[t.size||"md"]||40,r=i*.4;if(t.src){const h={width:`${i}px`,height:`${i}px`,borderRadius:"50%",objectFit:"cover",...t.className?e.parseClassName(t.className):{}},a=e.getCommonProps(n,h,t);return E("img",{key:n,src:t.src,alt:t.alt||t.label||"",...a})}const o=t.initials||(t.label||t.text||"").split(" ").map(h=>h[0]).join("").slice(0,2).toUpperCase()||"?",l={width:`${i}px`,height:`${i}px`,borderRadius:"50%",backgroundColor:t.bg||e.cfg.colors.primary,color:t.color||e.cfg.colors.text,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${r}px`,fontWeight:600,flexShrink:0,...t.className?e.parseClassName(t.className):{}},c=e.getCommonProps(n,l,t);return E("div",{key:n,...c},o)}function h1(e,t,n){const s=t.progressValue??t.value??0,i=t.progressMax??100,r=(p,g)=>{if(typeof p=="string")return Number(e.interpolateText(p))||g;const d=Number(p);return Number.isFinite(d)?d:g},o=r(s,0),l=r(i,100),c=Math.min(100,Math.max(0,o/l*100)),a=o>l?e.cfg.colors.danger:t.color||e.cfg.colors.primary,u={width:"100%",display:"flex",flexDirection:"column",gap:"4px",...t.className?e.parseClassName(t.className):{}},f=e.getCommonProps(n,u,t);return E("div",{key:n,...f},(t.progressLabel||t.label)&&m.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:e.cfg.colors.textMuted}},E("span",null,e.interpolateText(t.progressLabel||t.label||"")),E("span",null,`${o}/${l}`)),m.createElement("div",{style:{width:"100%",height:"8px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden"}},E("div",{style:{width:`${Math.min(c,100)}%`,height:"100%",backgroundColor:a,borderRadius:"4px",transition:"width 0.3s ease"}})))}function u1(e,t,n){const s={position:"relative",width:"100%",...t.className?e.parseClassName(t.className):{}},i=e.getCommonProps(n,s,t);return E("div",{key:n,...i},E("span",{style:{position:"absolute",left:"12px",top:"50%",transform:"translateY(-50%)",color:e.cfg.colors.textPlaceholder,fontSize:"14px",pointerEvents:"none"}},e.renderIcon("search",14)),E("input",{type:"text",name:t.name||"search",placeholder:t.placeholder||"Search...",value:e.sceneData[t.name||"search"]??"",onChange:r=>{e.setSceneData(o=>({...o,[t.name||"search"]:r.target.value}))},style:{width:"100%",padding:"8px 12px 8px 36px",borderRadius:e.cfg.layout.borderRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",fontSize:e.cfg.typography.baseFontSize,transition:e.cfg.effects.transition}}))}function d1(e,t,n){const s=Array.isArray(t.breadcrumbItems)?t.breadcrumbItems:[],i={display:"flex",alignItems:"center",gap:"4px",fontSize:"14px",...t.className?e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return E("nav",{key:n,...r,"aria-label":"Breadcrumb"},s.map((o,l)=>{const c=l===s.length-1;return m.createElement(m.Fragment,{key:`${n}-bc-${l}`},m.createElement(c?"span":"a",{style:{color:c?e.cfg.colors.textSecondary:e.cfg.colors.textMuted,fontWeight:c?600:400,cursor:c?"default":"pointer",textDecoration:"none",transition:e.cfg.effects.transition},...!c&&o.href?{href:o.href}:{},...!c&&o.onClick?{onClick:()=>e.handleButtonClick(o.onClick,{})}:{}},o.label),!c&&E("span",{style:{color:e.cfg.colors.border,margin:"0 2px"}},"/"))}))}function f1(e,t,n){const s=Array.isArray(t.items)?t.items:[],[i,r]=m.useState(0),o=t.autoplay!==!1&&s.length>1,l=t.interval||4e3,c=t.effect==="fade"?"fade":"slide";m.useEffect(()=>{if(!o||s.length<2)return;const x=setInterval(()=>r(k=>(k+1)%s.length),l);return()=>clearInterval(x)},[o,l,s.length]);const h=x=>r((x%s.length+s.length)%s.length),a=t.showArrows!==!1&&s.length>1,u=t.showDots!==!1&&s.length>1,f={position:"relative",overflow:"hidden",...t.className?e.parseClassName(t.className):{}};t.aspectRatio&&(f.aspectRatio=t.aspectRatio),!t.aspectRatio&&!t.height&&(f.height="320px");const p=e.getCommonProps(n,f,t),g=x=>typeof x=="string"?{type:"text",text:x}:x&&x.image?{type:"image",src:x.image,alt:x.alt||"",title:x.title}:x,d=s.map((x,k)=>{const S=e.renderComponent({...g(x),key:void 0},k,`${n}-slide`),T={width:"100%",height:"100%",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"};return c==="fade"?(T.position="absolute",T.inset="0",T.opacity=k===i?1:0,T.transition="opacity .5s ease",T.pointerEvents=k===i?"auto":"none"):T.flexShrink=0,E("div",{key:`${n}-item-${k}`,style:T},S)}),w=c==="fade"?{position:"relative",width:"100%",height:"100%"}:{display:"flex",height:"100%",transition:"transform .5s ease",transform:`translateX(-${i*100}%)`},C={position:"absolute",top:"50%",transform:"translateY(-50%)",zIndex:2,width:"36px",height:"36px",borderRadius:"50%",border:"none",background:"rgba(0,0,0,0.45)",color:"#fff",fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};return E("div",{key:n,...p},E("div",{style:w},d),a&&E("div",{style:{...C,left:"8px"}},E("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>h(i-1),"aria-label":"Previous slide"},"<")),a&&E("div",{style:{...C,right:"8px"}},E("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>h(i+1),"aria-label":"Next slide"},">")),u&&E("div",{style:{position:"absolute",bottom:"10px",left:"50%",transform:"translateX(-50%)",display:"flex",gap:"6px",zIndex:2}},s.map((x,k)=>E("button",{key:`${n}-dot-${k}`,"aria-label":`Slide ${k+1}`,onClick:()=>h(k),style:{width:"10px",height:"10px",borderRadius:"50%",border:"none",cursor:"pointer",padding:0,background:k===i?"rgba(255,255,255,0.95)":"rgba(255,255,255,0.4)",transition:"background .3s ease"}}))))}function m1(e,t,n){const s=Array.isArray(t.items)?t.items:[],i=t.speed||20,r={overflow:"hidden",width:"100%",...t.className?e.parseClassName(t.className):{}},o=e.getCommonProps(n,r,t),l=c=>E("div",{key:c,style:{display:"inline-flex",alignItems:"center",gap:t.gap||"24px",paddingRight:t.gap||"24px",animation:`bf-marquee ${i}s linear infinite`,willChange:"transform",flexShrink:0}},s.map((h,a)=>{const u=typeof h=="string"?{type:"text",text:h}:h&&h.image?{type:"image",src:h.image,alt:h.alt||"",height:t.itemHeight||"48px"}:h;return e.renderComponent(u,a,`${c}-${n}-marq`)}));return E("div",{key:n,...o},E("div",{style:{display:"flex",width:"max-content"}},l("a"),l("b")))}function p1(e,t,n){const s=m.useRef(null),i=m.useRef(null),r=m.useRef(null),[o,l]=m.useState("idle"),[c,h]=m.useState(""),[a,u]=m.useState(!1),f=t.fieldName||"capture",p=t.captureMode==="qr",g=e.apiUrl||window.location.origin,d=t.uploadPath||"/api/files/upload",w=()=>{var H;(H=i.current)==null||H.getTracks().forEach(U=>U.stop()),i.current=null},C=async H=>{var j,D,V;const U=new FormData;U.append("file",H,`${f}-${Date.now()}.jpg`);const q=await fetch(new URL(d,g).toString(),{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`},body:U});if(!q.ok)throw new Error("Upload failed");const X=await q.json();return((j=X==null?void 0:X.file)==null?void 0:j.url)||((D=X==null?void 0:X.file)==null?void 0:D.publicUrl)||((V=X==null?void 0:X.file)==null?void 0:V.path)||(X==null?void 0:X.url)||(X==null?void 0:X.path)||""},x=async(H,U)=>{var q,X;if(o!=="done"){w();try{u(!0);const j=U||await C(H);e.setSceneData(D=>({...D,[f]:j})),h(j),l("done"),(q=e.showToast)==null||q.call(e,t.successMessage||(U?"Scanned!":"Captured & uploaded"),"success")}catch{l("error"),(X=e.showToast)==null||X.call(e,"Capture failed","error")}finally{u(!1)}}},k=()=>{var q;const H=s.current;if(!H||!H.videoWidth)return;const U=document.createElement("canvas");U.width=H.videoWidth,U.height=H.videoHeight,(q=U.getContext("2d"))==null||q.drawImage(H,0,0),U.toBlob(X=>X&&x(X),"image/jpeg",t.quality||.85)},S=async()=>{var H,U;try{const q=await navigator.mediaDevices.getUserMedia({video:{facingMode:t.facingMode||"user",...t.aspectRatio?{aspectRatio:Number(t.aspectRatio)}:{}},audio:!1});if(i.current=q,s.current&&(s.current.srcObject=q,await s.current.play().catch(()=>{})),l("running"),p){const j=window.BarcodeDetector;if(!j){l("error"),(H=e.showToast)==null||H.call(e,"QR scanning not supported in this browser","error");return}const D=new j;r.current=window.setInterval(async()=>{const V=s.current;if(!(!V||!V.videoWidth||o==="done"))try{const J=await D.detect(V);J!=null&&J.length&&x(new Blob,J[0].rawValue)}catch{}},400)}}catch{l("error"),(U=e.showToast)==null||U.call(e,"Camera access denied","error")}};m.useEffect(()=>(S(),()=>{r.current&&window.clearInterval(r.current),w()}),[]);const T={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",width:"100%",...t.className?e.parseClassName(t.className):{}},P=e.getCommonProps(n,T,t),I=E("video",{key:"cam-video",ref:s,autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a",display:p||o!=="done"?void 0:"none"}}),L=c?E("img",{key:"cam-result",src:c,alt:"captured",style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a"}}):null,O=E("div",{key:"cam-actions",style:{display:"flex",gap:"10px",flexWrap:"wrap",justifyContent:"center"}},o!=="done"?E("button",{key:"cam-capture",onClick:k,disabled:a||o!=="running",style:{padding:"10px 22px",borderRadius:"9999px",border:"none",cursor:a?"wait":"pointer",background:"#3B82F6",color:"#fff",fontWeight:600}},a?"Uploading...":p?t.captureLabel||"Scan QR":t.captureLabel||"Capture"):E("button",{key:"cam-retake",onClick:()=>{h(""),l("idle"),S()},style:{padding:"10px 22px",borderRadius:"9999px",border:"1px solid #94a3b8",cursor:"pointer",background:"transparent"}},"Retake"));return E("div",{key:n,...P},I,L,t.captureLabel===!1?null:O,o==="error"?E("p",{key:"cam-err",style:{color:"#EF4444",fontSize:"13px"}},"Camera unavailable — check permissions"):null)}function g1(e,t,n){var i;if(t.className){const r=((i=e.parseClassNameResponsive)==null?void 0:i.call(e,t.className,n))??e.parseClassName(t.className),o=e.getCommonProps(n,r,t);return E("div",{key:n,className:t.className,...o})}const s=e.getCommonProps(n,{height:t.h||t.height||"24px"},t);return E("div",{key:n,...s})}function y1(e,t,n){const s=t.className||"border-gray-700 my-4",i=e.parseClassName(s),r=e.getCommonProps(n,i,t);return E("hr",{key:n,className:s,...r})}function b1(e,t,n){var a;const s=t.loaderVariant||"spinner",i=t.rows||3,r=t.className?((a=e.parseClassNameResponsive)==null?void 0:a.call(e,t.className,n))??e.parseClassName(t.className):{};t.rawStyle&&Object.assign(r,t.rawStyle);const o=e.getCommonProps(n,r,t),l=`${e.scopeId}-${n}`,c=e.renderMode==="css-driven"?{"data-bf-r":l}:{};if(s==="skeleton"){const u=[];for(let f=0;f<i;f++){const p=t.width||(f===i-1?"60%":"100%");u.push(E("div",{key:f,className:"bf-loader-skeleton",style:{height:t.height||"16px",width:p,borderRadius:"6px",marginBottom:f<i-1?"12px":"0"}}))}return E("div",{key:n,className:t.className,style:r,...o,...c},...u)}if(s==="shimmer"){const u=[];for(let f=0;f<i;f++){const p=t.width||(f===i-1?"60%":"100%");u.push(E("div",{key:f,className:"bf-loader-shimmer",style:{height:t.height||"16px",width:p,borderRadius:"6px",marginBottom:f<i-1?"12px":"0"}}))}return E("div",{key:n,className:t.className,style:r,...o,...c},...u)}if(s==="dots"){const u=t.color||"currentColor";return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",gap:"6px",...r},...o,...c},[0,1,2].map(f=>E("div",{key:f,className:"bf-loader-dot",style:{width:t.size||"8px",height:t.size||"8px",borderRadius:"50%",backgroundColor:u,animationDelay:`${f*.16}s`}})))}if(s==="pulse")return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...r},...o,...c},E("div",{className:"bf-loader-pulse",style:{width:t.size||"32px",height:t.size||"32px",borderRadius:"50%",border:`3px solid ${t.color||"currentColor"}`}}));if(s==="progress")return E("div",{key:n,className:t.className,style:{width:"100%",...r},...o,...c},E("div",{style:{height:t.height||"4px",width:"100%",backgroundColor:"rgba(128,128,128,0.2)",borderRadius:"4px",overflow:"hidden"}},E("div",{className:"bf-loader-progress-bar",style:{height:"100%",width:"30%",backgroundColor:t.color||"currentColor",borderRadius:"4px"}})));const h=t.size||"24px";return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...r},...o,...c},E("div",{className:"bf-loader-spinner",style:{width:h,height:h,border:`3px solid ${t.color?t.color+"33":"rgba(128,128,128,0.2)"}`,borderTopColor:t.color||"currentColor",borderRadius:"50%"}}))}function v1(e,t,n){const s=t.rows||4;if(t.className){const o=e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("textarea",{key:n,className:t.className,...l,name:t.name,placeholder:t.placeholder,rows:s})}const i={width:"100%",padding:"0.75rem 1rem",borderRadius:e.cfg.components.inputRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,resize:"vertical",fontFamily:"inherit"},r=e.getCommonProps(n,i,t);if(t.label){const o=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...o},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("textarea",{...r,name:t.name,placeholder:t.placeholder,rows:s}))}return E("textarea",{key:n,...r,name:t.name,placeholder:t.placeholder,rows:s})}function x1(e,t,n){const s=t.icon||t.name||"",i=t.size||24,r=e.renderIcon(s,i);if(t.className){const o=e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("span",{key:n,className:t.className,...l},r)}return m.cloneElement(r,{key:n})}function w1(e,t,n){const s=t.metricSize||"md",i=s==="sm"?"1.25rem":s==="lg"?"2.5rem":"1.75rem",r=s==="sm"?"0.75rem":s==="lg"?"1rem":"0.875rem",o=t.color||e.cfg.colors.primary,l=t.trend==="up"?"↑":t.trend==="down"?"↓":"",c=t.trendColor||(t.trend==="up"?e.cfg.colors.success:t.trend==="down"?e.cfg.colors.danger:e.cfg.colors.textMuted),h={display:"flex",flexDirection:"column",gap:"2px",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},a=e.getCommonProps(n,h,t);return E("div",{key:n,...a},t.label&&E("span",{style:{fontSize:r,color:e.cfg.colors.textSecondary,fontWeight:500}},e.interpolateText(t.label)),m.createElement("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",marginTop:"4px"}},t.prefix&&E("span",{style:{fontSize:i,fontWeight:700,color:o}},t.prefix),E("span",{style:{fontSize:i,fontWeight:700,color:e.cfg.colors.text}},typeof t.value=="number"?t.value.toLocaleString():e.interpolateText(String(t.value??""))),t.suffix&&E("span",{style:{fontSize:i,fontWeight:700,color:o}},t.suffix),t.delta&&E("span",{style:{fontSize:"0.75rem",fontWeight:600,color:c,marginLeft:"4px"}},`${l} ${t.delta}`)))}function S1(e,t,n){const s=t.chartData||t.data||[];if(!Array.isArray(s)||s.length===0)return null;const i=t.height||200,r=t.barColor||e.cfg.colors.primary,o=t.showValues!==!1,l=t.horizontal===!0,c=t.maxValue||Math.max(...s.map(f=>f.value),1),h=l?8:Math.max(4,Math.min(20,300/s.length)),a={width:"100%",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.title?{}:{},...t.className?e.parseClassName(t.className):{}},u=e.getCommonProps(n,a,t);return E("div",{key:n,...u},t.title&&E("div",{style:{fontSize:"0.875rem",fontWeight:600,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem",textAlign:"center"}},t.title),E("div",{style:{display:"flex",flexDirection:l?"column":"row",alignItems:l?"stretch":"flex-end",justifyContent:"center",gap:`${h}px`,height:l?void 0:`${i}px`,width:l?"100%":void 0,minHeight:l?void 0:`${i}px`,padding:"4px 0"}},...s.map((f,p)=>{const g=c>0?f.value/c*100:0,d=f.color||r;return l?E("div",{key:p,style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"}},E("span",{style:{fontSize:"0.75rem",color:e.cfg.colors.textSecondary,minWidth:"60px",textAlign:"right",flexShrink:0}},f.label),E("div",{style:{flex:1,height:"20px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden",position:"relative"}},E("div",{style:{width:`${g}%`,height:"100%",backgroundColor:d,borderRadius:"4px",transition:"width 0.5s ease"}})),o&&E("span",{style:{fontSize:"0.7rem",color:e.cfg.colors.textMuted,minWidth:"32px",fontVariantNumeric:"tabular-nums"}},typeof f.value=="number"?f.value.toLocaleString():String(f.value))):E("div",{key:p,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",flex:1,height:"100%",maxWidth:"60px"}},o&&E("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textMuted,marginBottom:"2px",fontVariantNumeric:"tabular-nums"}},typeof f.value=="number"?f.value.toLocaleString():String(f.value)),E("div",{style:{width:"100%",height:`${g}%`,backgroundColor:d,borderRadius:"4px 4px 0 0",transition:"height 0.5s ease",minHeight:g>0?"4px":"0px"}}),E("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textSecondary,marginTop:"4px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"}},f.label))})))}function Go(e,t,n,s=!1,i=!1){const r=Array.isArray(t.chartData)?t.chartData:[];if(r.length===0)return null;const o=r.flatMap(k=>i?[k.low,k.high]:[k.value]).map(Number).filter(Number.isFinite);if(o.length===0)return null;const l=Math.min(...o),h=Math.max(...o)-l||1,a=Number(t.height)||220,u=640,f=k=>r.length===1?u/2:k/(r.length-1)*u,p=k=>a-(k-l)/h*a,g=r.map((k,S)=>`${f(S)},${p(Number(k.value))}`).join(" "),d=t.lineColor||e.cfg.colors.accent,w=t.fillColor||`${d}33`,C={width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},x=i?r.map((k,S)=>{const T=Number(k.open),P=Number(k.close),I=Number(k.high),L=Number(k.low),O=P>=T;return E("div",{key:S,style:{flex:1,height:"100%",position:"relative"}},E("div",{style:{position:"absolute",left:"50%",top:`${p(I)}px`,height:`${Math.max(1,p(L)-p(I))}px`,borderLeft:`1px solid ${O?"#22c55e":"#ef4444"}`}}),E("div",{style:{position:"absolute",left:"25%",right:"25%",top:`${p(Math.max(T,P))}px`,height:`${Math.max(3,Math.abs(p(P)-p(T)))}px`,background:O?"#22c55e":"#ef4444",borderRadius:"2px"}}))}):m.createElement("svg",{viewBox:`0 0 ${u} ${a}`,preserveAspectRatio:"none",style:{width:"100%",height:a}},t.showGrid!==!1&&[25,50,75].map(k=>m.createElement("line",{key:k,x1:0,x2:u,y1:a*k/100,y2:a*k/100,stroke:e.cfg.colors.borderSubtle,strokeDasharray:"3 4"})),s&&m.createElement("polygon",{points:`0,${a} ${g} ${u},${a}`,fill:w}),m.createElement("polyline",{points:g,fill:"none",stroke:d,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round"}));return E("div",{key:n,style:e.getCommonProps(n,C,t)},t.title&&E("div",{style:{color:e.cfg.colors.textSecondary,fontWeight:600,marginBottom:"0.75rem"}},t.title),E("div",{style:{display:"flex",alignItems:"stretch",gap:i?"4px":void 0,height:a}},x),E("div",{style:{display:"flex",justifyContent:"space-between",color:e.cfg.colors.textMuted,fontSize:"0.7rem",marginTop:"4px"}},...r.map((k,S)=>E("span",{key:S},k.label||""))))}function C1(e,t,n){const s=Array.isArray(t.chartData)?t.chartData[0]||{}:{},i=t.ticker||s.ticker||s.symbol||"EUR/USD",r=t.bid??s.bid??s.price,o=t.ask??s.ask,l=t.change??s.change,c=Number(l),h=Number.isFinite(c)&&c>=0,a=e.getCommonProps(n,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",width:"100%",padding:"0.9rem 1rem",backgroundColor:e.cfg.colors.surface,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:e.cfg.layout.borderRadiusLg,...t.className?e.parseClassName(t.className):{}},t);return E("div",{key:n,...a},E("div",{},E("div",{style:{color:e.cfg.colors.text,fontWeight:700}},i),t.label&&E("div",{style:{color:e.cfg.colors.textMuted,fontSize:"0.75rem"}},t.label)),E("div",{style:{display:"flex",gap:"1rem",alignItems:"baseline",fontVariantNumeric:"tabular-nums"}},r!=null&&E("span",{style:{color:e.cfg.colors.text,fontWeight:700}},String(r)),o!=null&&E("span",{style:{color:e.cfg.colors.textSecondary}},String(o)),l!=null&&E("span",{style:{color:h?"#22c55e":"#ef4444",fontSize:"0.8rem",fontWeight:600}},`${h?"+":""}${l}`)))}function k1({api:e,c:t,componentKey:n}){var w,C,x,k;const s=m.useRef(null),i=m.useRef(null),r=m.useRef(null),[o,l]=m.useState(null),c=m.useRef(null),[h,a]=m.useState(()=>Array.isArray(t.chartData)?t.chartData:[]);m.useEffect(()=>{Array.isArray(t.chartData)&&a(t.chartData)},[t.chartData]);const u=e.interpolateText(((w=t.realtime)==null?void 0:w.channel)||""),f=e.interpolateText(((C=t.timeRange)==null?void 0:C.from)||""),p=e.interpolateText(((x=t.timeRange)==null?void 0:x.to)||""),g=Array.isArray(t.timeframes)?t.timeframes:[];m.useEffect(()=>{var I,L;const S=e.sdk;if(!(((I=t.realtime)==null?void 0:I.mode)==="ws"&&e.isAuthenticated&&u&&((L=S==null?void 0:S.client)==null?void 0:L.createWebSocket)))return;const P=S.client.createWebSocket(u);return P.onmessage=O=>{var H;try{const U=typeof O.data=="string"?JSON.parse(O.data):O.data,q=(U==null?void 0:U.tick)||((H=U==null?void 0:U.data)==null?void 0:H.tick)||(U==null?void 0:U.data)||U,X=Number((q==null?void 0:q.quote)??(q==null?void 0:q.price)??(q==null?void 0:q.close));if(!Number.isFinite(X))return;const j=Number((q==null?void 0:q.epoch)??(q==null?void 0:q.timestamp)??Date.now()/1e3),D=Math.floor(j/60)*60;a(V=>{const J=V[V.length-1];if((J==null?void 0:J.time)===D)return[...V.slice(0,-1),{...J,high:Math.max(Number(J.high),X),low:Math.min(Number(J.low),X),close:X}];const nt=Number((J==null?void 0:J.close)??X);return[...V.slice(-99),{time:D,open:nt,high:X,low:X,close:X}]})}catch{}},()=>{var O;return(O=P.close)==null?void 0:O.call(P)}},[e.isAuthenticated,(k=t.realtime)==null?void 0:k.mode,u]);const d=m.useMemo(()=>h.map((S,T)=>{const P=S.time||S.timestamp;return{time:typeof P=="string"&&P.includes("T")?Math.floor(new Date(P).getTime()/1e3):P||`2024-01-${String(T+1).padStart(2,"0")}`,...t.chartType==="candlestick"?{open:Number(S.open),high:Number(S.high),low:Number(S.low),close:Number(S.close)}:{value:Number(S.value??S.close)}}}),[t.chartType,h]);return c.current=d[d.length-1],m.useEffect(()=>{const S=s.current;if(!S)return;const T=Pw(S,{autoSize:!0,height:Number(t.height)||280,layout:{background:{color:"transparent"},textColor:e.cfg.colors.textSecondary},grid:{vertLines:{color:e.cfg.colors.borderSubtle},horzLines:{color:e.cfg.colors.borderSubtle}},rightPriceScale:{borderColor:e.cfg.colors.borderSubtle},timeScale:{borderColor:e.cfg.colors.borderSubtle,timeVisible:!0}}),P=t.chartType||"candlestick",I=P==="line"?T.addSeries(zw,{color:t.lineColor||e.cfg.colors.accent}):P==="area"?T.addSeries(Hw,{lineColor:t.lineColor||e.cfg.colors.accent,topColor:t.fillColor||`${e.cfg.colors.accent}66`,bottomColor:"transparent"}):T.addSeries(Xw,{upColor:"#22c55e",downColor:"#ef4444",borderVisible:!1,wickUpColor:"#22c55e",wickDownColor:"#ef4444"});return r.current=T,i.current=I,()=>{i.current=null,r.current=null,T.remove()}},[e.cfg.colors.accent,e.cfg.colors.borderSubtle,e.cfg.colors.textSecondary,t.chartType,t.height,t.lineColor,t.fillColor]),m.useEffect(()=>{var S,T;!i.current||d.length===0||(i.current.setData(d),f&&p?(S=r.current)==null||S.timeScale().setVisibleRange({from:f,to:p}):(T=r.current)!=null&&T.timeScale().getVisibleLogicalRange()||r.current.timeScale().fitContent())},[d,f,p]),m.useEffect(()=>{if(!o||!r.current||!c.current)return;const S={"1H":3600,"4H":14400,"1D":86400,"1W":604800}[o],T=Number(c.current.time);S&&Number.isFinite(T)&&r.current.timeScale().setVisibleRange({from:T-S,to:T})},[o]),E("div",{key:n,style:{width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}}},g.length>0&&E("div",{style:{display:"flex",gap:"0.35rem",marginBottom:"0.5rem"}},...g.map(S=>E("button",{key:S,type:"button",onClick:()=>l(S),style:{padding:"0.3rem 0.6rem",border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:4,color:e.cfg.colors.text,background:o===S?e.cfg.colors.surfaceHover:"transparent",cursor:"pointer"}},S))),E("div",{ref:s,style:{width:"100%",height:Number(t.height)||280}}))}function M1(e,t,n){return m.createElement(k1,{api:e,c:t,componentKey:n})}function E1(e,t,n){const s=t.json||t.data||t.diagram||{},i=e.getCommonProps(n,{display:"flex",flexDirection:"column",minHeight:"300px"},t);return E("div",{key:n,className:t.className,...i},m.createElement("pre",{style:{fontSize:"12px",whiteSpace:"pre-wrap",margin:0}},typeof s=="string"?s:JSON.stringify(s,null,2)))}function T1({api:e,c:t,componentKey:n}){const s=t.data||t.json||t.diagram||{},{_config:i,...r}=s||{},o=Object.keys(r).length?r:s,{nodes:l,edges:c}=m.useMemo(()=>dc.createFlowDiagram(o),[o]),[h,a]=m.useState("LR"),u=e.cfg.fullscreen===!0,f=t.height||(u?"100%":320),p=e.getCommonProps(n,{width:"100%",height:f,...u?{minHeight:0}:{}},t);return E("div",{key:n,className:t.className,...p},m.createElement(dc.FlowDiagram,{nodes:l,edges:c,config:{direction:h,layout:(i==null?void 0:i.layout)||"dagre",colorMode:(i==null?void 0:i.colorMode)||(e.cfg.colorMode==="dark"?"dark":"light"),backgroundPattern:(i==null?void 0:i.backgroundPattern)||"dot"},callbacks:{onDirectionChange:g=>a(g)},showBottomBar:(i==null?void 0:i.showBottomBar)||!1,style:{width:"100%",height:"100%"}}))}function A1(e,t,n){return m.createElement(T1,{api:e,c:t,componentKey:n})}function R1(e,t,n){var s;if(t.className){const i=((s=e.parseClassNameResponsive)==null?void 0:s.call(e,t.className,n))??e.parseClassName(t.className);i.display==null&&(i.display="flex"),i.flexDirection==null&&(i.flexDirection=/(^|\s)flex(\s|$)/.test(t.className||"")||t.layout==="row"?"row":"column");const r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,className:t.className,...r},(Array.isArray(t.children)?t.children:[]).map((o,l)=>e.renderComponent(o,l,n)))}return null}const P1=m.memo(({api:e,field:t,fieldName:n,value:s,onChange:i})=>{m.useEffect(()=>{s!==void 0&&s!==""&&i&&i(s)},[]);const r=m.useRef(null),[o,l]=m.useState(!1),c=m.useRef(null),h=m.useRef(null),[a,u]=m.useState(!1),[f,p]=m.useState(""),[g,d]=m.useState(!1),w=t.html!==!1,C=x=>w?x:x.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\n/g,"<br>");return m.useEffect(()=>{r.current&&!r.current.innerHTML&&(r.current.innerHTML=C(s))},[]),m.useEffect(()=>{r.current&&document.activeElement!==r.current&&r.current.innerHTML!==s&&(r.current.innerHTML=C(s))},[s]),m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,m.createElement("div",{style:{border:`1px solid ${o?e.cfg.colors.primary:e.cfg.colors.border}`,borderRadius:e.cfg.components.inputRadius,overflow:"hidden",transition:"border-color 0.2s",position:"relative"}},m.createElement("div",{style:{display:"flex",gap:"4px",padding:"6px 8px",borderBottom:`1px solid ${e.cfg.colors.border}`,backgroundColor:e.cfg.colors.surface}},...[{cmd:"bold",label:"B"},{cmd:"italic",label:"I"},{cmd:"underline",label:"U"}].map(x=>E("button",{key:x.cmd,type:"button",onMouseDown:k=>{var S;k.preventDefault(),document.execCommand(x.cmd,!1),(S=r.current)==null||S.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontWeight:600,fontSize:"13px"},onMouseEnter:k=>k.target.style.borderColor=e.cfg.colors.border,onMouseLeave:k=>k.target.style.borderColor="transparent"},x.label)),E("span",{key:"spacer",style:{flex:1}}),E("button",{key:"list-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),document.execCommand("insertUnorderedList",!1),(k=r.current)==null||k.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},"☰"),E("span",{key:"divider",style:{width:"1px",height:"16px",backgroundColor:e.cfg.colors.border,margin:"0 4px",alignSelf:"center"}}),E("button",{key:"img-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),(k=c.current)==null||k.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("image",14)),E("button",{key:"att-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),(k=h.current)==null||k.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("paperclip",14)),E("button",{key:"ai-btn",type:"button",onMouseDown:x=>{x.preventDefault(),u(!a)},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:a?e.cfg.colors.border:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("sparkles",14))),E("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onInput:x=>i(x.currentTarget.innerHTML),onFocus:()=>l(!0),onBlur:()=>l(!1),style:{minHeight:(t.rows||10)*20+"px",padding:"0.75rem 1rem",backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,outline:"none",fontSize:"0.875rem",lineHeight:"1.6"}}),t.expandAction?m.createElement("button",{type:"button",key:"expand",style:{position:"absolute",bottom:"6px",left:"6px",background:"rgba(0,0,0,0.55)",border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"3px 5px",display:"flex",alignItems:"center",justifyContent:"center",opacity:.5,transition:"opacity 0.2s",zIndex:1},onMouseEnter:x=>{x.currentTarget.style.opacity="0.85"},onMouseLeave:x=>{x.currentTarget.style.opacity="0.5"},onClick:x=>{x.preventDefault(),x.stopPropagation(),e.handleButtonClick(t.expandAction,{})}},e.renderIcon("maximize-2",13)):null,E("input",{key:"img-input",ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:async x=>{var S,T,P,I,L,O;const k=(S=x.target.files)==null?void 0:S[0];if(k){try{const H=(T=e.showToast)==null?void 0:T.call(e,"Uploading image (0%)…","success",0),U=e.uploadFile?await e.uploadFile(k,t.upload,q=>{var X;return(X=H==null?void 0:H.update)==null?void 0:X.call(H,`Uploading image (${q}%)`)}):"";if((P=H==null?void 0:H.dismiss)==null||P.call(H),!U)throw Error();(I=r.current)==null||I.focus(),document.execCommand("insertImage",!1,U),i(((L=r.current)==null?void 0:L.innerHTML)||"")}catch{(O=e.showToast)==null||O.call(e,"Failed to upload image","error")}x.target.value=""}}}),E("input",{key:"att-input",ref:h,type:"file",multiple:!0,style:{display:"none"},onChange:async x=>{var I,L,O,H,U;const k=Array.from(x.target.files||[]);x.target.value="";const S=[];let T=0;const P=(I=e.showToast)==null?void 0:I.call(e,`Uploading 0/${k.length}…`,"success",0);for(const q of k){try{const X=e.uploadFile?await e.uploadFile(q,t.upload,j=>{var D;return(D=P==null?void 0:P.update)==null?void 0:D.call(P,`Uploading ${q.name} (${j}%)`)}):"";if(!X)throw Error();S.push(`<a href="${X}">${q.name}</a>`)}catch{(L=e.showToast)==null||L.call(e,`Failed to upload ${q.name}`,"error")}T++,(O=P==null?void 0:P.update)==null||O.call(P,`Uploading ${T}/${k.length}…`)}if((H=P==null?void 0:P.dismiss)==null||H.call(P),S.length>0&&r.current){r.current.focus();const q=window.getSelection();if(q){q.removeAllRanges();const X=document.createRange();X.selectNodeContents(r.current),X.collapse(!1),q.addRange(X)}document.execCommand("insertHTML",!1,`<br><br>${S.join(", ")}`),i(((U=r.current)==null?void 0:U.innerHTML)||"")}}}),a?E("div",{key:"ai-popup",style:{position:"absolute",bottom:"100%",left:"8px",right:"8px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",padding:"12px",zIndex:10,boxShadow:"0 -4px 24px rgba(0,0,0,0.4)"}},E("textarea",{value:f,onChange:x=>p(x.target.value),placeholder:"Ask AI to draft a reply...",rows:3,style:{width:"100%",padding:"8px 12px",borderRadius:"4px",border:`1px solid ${e.cfg.colors.borderSubtle}`,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,fontSize:"13px",outline:"none",fontFamily:"inherit",resize:"none",boxSizing:"border-box"}}),E("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"8px"}},E("button",{type:"button",onClick:()=>{u(!1),p("")},style:{padding:"6px 14px",borderRadius:"6px",border:`1px solid ${e.cfg.colors.borderSubtle}`,cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textMuted,fontSize:"12px",fontFamily:"inherit"}},"Cancel"),E("button",{type:"button",disabled:g||!f.trim(),onClick:async()=>{var x,k,S,T;if(!(!f.trim()||g)){d(!0);try{const P=((x=r.current)==null?void 0:x.innerHTML)||"",I=await fetch("/api/tenant/email/ai/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f,context:P})});if(!I.ok)throw Error();const L=await I.json(),O=L.response||L.text||L.content||"";(k=r.current)==null||k.focus(),document.execCommand("insertText",!1,O),i(((S=r.current)==null?void 0:S.innerHTML)||""),u(!1),p("")}catch{(T=e.showToast)==null||T.call(e,"AI request failed","error")}d(!1)}},style:{padding:"6px 14px",borderRadius:"6px",border:"none",cursor:g||!f.trim()?"not-allowed":"pointer",backgroundColor:g||!f.trim()?e.cfg.colors.surfaceHover:e.cfg.colors.background,color:g||!f.trim()?e.cfg.colors.textSecondary:e.cfg.colors.text,fontSize:"12px",fontWeight:600,fontFamily:"inherit"}},g?"Thinking...":"Generate"))):null))}),_1=m.memo(({api:e,c:t,componentKey:n})=>{const[s,i]=m.useState(!1),r=m.useRef(null),[o,l]=m.useState([]),c=t.name?`bf_persist_${t.name}`:null;m.useEffect(()=>{t.dataSource&&(async()=>{var u;try{const f=e.interpolateText(t.dataSource),p=(u=e.selectDynamicOptions)==null?void 0:u[f];if(p&&p.length>0){l(p);return}En[f]||(En[f]=(async()=>{var d;try{const w=await fetch(f,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!w.ok)return[];const C=await w.json(),x=t.dataField||"configs",k=t.optionLabel||"label",S=t.optionValue||"value",T=C[x]||C.data||C,P=Array.isArray(T)?T.map(I=>({label:I[k]||I.name||I.label,value:I[S]||I.id||I.name||I.label})):[];return(d=e.setSelectDynamicOptions)==null||d.call(e,I=>({...I,[f]:P})),P}catch{return delete En[f],[]}})());const g=await En[f];g.length>0&&l(g)}catch{}})()},[t.dataSource]),m.useEffect(()=>{if(c&&t.name&&!e.sceneData[t.name]){const f=localStorage.getItem(c);f&&e.setSceneData(p=>({...p,[t.name]:f}))}},[c,t.name,e.sceneData[t.name]]),m.useEffect(()=>{if(!s)return;const u=p=>{r.current&&!r.current.contains(p.target)&&i(!1)},f=setTimeout(()=>{document.addEventListener("mousedown",u)},0);return()=>{clearTimeout(f),document.removeEventListener("mousedown",u)}},[s]);const h=t.variant==="selector",a=Array.isArray(t.items)?t.items:o;if(h){const u=t.name&&(e.sceneData[t.name||""]||c&&localStorage.getItem(c))||"",f=u||t.placeholder||"Select...";return E("div",{ref:r,style:{position:"relative",display:"inline-flex"}},m.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:t.fontSize||"1rem",fontWeight:t.fontWeight||600,color:t.color||e.cfg.colors.text,padding:"2px 0",outline:"none",lineHeight:"1.5"},onClick:p=>{p.preventDefault(),i(!s)}},E("span",{key:"text"},f),E("span",{key:"caret",style:{display:"flex",alignItems:"center",opacity:.6,marginLeft:"2px"}},e.renderIcon("chevron-down",14))),s?m.createElement("div",{style:{position:"absolute",top:"100%",left:"0",marginTop:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden",minWidth:"200px"}},...a.map((p,g)=>m.createElement("button",{key:g,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none",whiteSpace:"nowrap"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent"},onClick:d=>{d.preventDefault(),d.stopPropagation(),i(!1),t.name&&p.value!==u&&e.setSceneData(w=>({...w,[t.name]:p.value}))}},p.label||""))):null)}return m.createElement("div",{ref:r,style:{position:"relative",display:"flex",width:"100%"}},(()=>{var p;const u=!!((p=e.buttonLoading)!=null&&p[n]),f=[];return u?f.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):t.icon&&f.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(t.icon,t.iconSize||16))),f.push(E("span",{key:"text",style:{lineHeight:"1"}},t.text||"Button")),m.createElement("button",{type:"button",style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontSize:"0.875rem",fontWeight:600,fontFamily:"inherit",lineHeight:"1.25rem",transition:"all 0.15s ease",outline:"none"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=e.cfg.colors.border,g.currentTarget.style.color=e.cfg.colorMode==="light"?"#111827":e.cfg.colors.text},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",g.currentTarget.style.color=e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary},onClick:g=>{if(g.preventDefault(),a.length>0&&a[0].onClick){const d=()=>e.handleButtonClick(a[0].onClick,{onSuccess:a[0].onSuccess,onError:a[0].onError},{feedback:a[0].feedback,optimistic:a[0].optimistic,payload:a[0].payload});(e.withLoading?e.withLoading(n,d):d()).catch(()=>{})}}},...f)})(),a.length>0?m.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0.75rem 0.5rem",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,borderLeft:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s ease",outline:"none"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor=e.cfg.colors.border,u.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.color=e.cfg.colors.textSecondary},onClick:u=>{u.preventDefault(),u.stopPropagation(),i(!s)}},e.renderIcon("chevron-down",16)):null,s?m.createElement("div",{style:{position:"absolute",bottom:"100%",left:"0",right:"0",marginBottom:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 -8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden"}},...a.map((u,f)=>{var w;const p=`${n}-item-${f}`,g=!!((w=e.buttonLoading)!=null&&w[p]),d=[];return g?d.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):u.icon&&d.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"8px"}},e.renderIcon(u.icon,14))),d.push(u.label||""),m.createElement("button",{key:f,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},onClick:C=>{if(C.preventDefault(),C.stopPropagation(),!u.onClick)return;const x=u.loading==="self"?p:n;u.loading==="self"?i(!0):i(!1);const k=()=>e.handleButtonClick(u.onClick,{onSuccess:u.onSuccess,onError:u.onError},{feedback:u.feedback,optimistic:u.optimistic,payload:u.payload});(e.withLoading?e.withLoading(x,k):k()).finally(()=>{u.loading==="self"&&i(!1)}).catch(()=>{})}},...d)})):null)});function $1(e,t,n){return m.createElement(_1,{api:e,c:t,componentKey:n})}function N1(e,t,n){var c,h;const s=t.widgetId;if(!s)return null;const r=(e.widgets||[]).find(a=>a.id===s);if(!r||!Array.isArray(r.components))return Br(`[renderer] widget "${s}" not found`),null;if(e.widgetStack&&e.widgetStack.includes(s))return Br(`[renderer] circular widget reference "${s}"`),null;(c=e.widgetStack)==null||c.push(s);const o=t.props||{},l=Ea(r.components,o).map((a,u)=>e.renderComponent(a,u,`${n}-${s}`));return(h=e.widgetStack)==null||h.pop(),m.createElement(m.Fragment,null,...l)}function Ea(e,t){if(!t||Object.keys(t).length===0)return e;if(Array.isArray(e))return e.map(n=>Ea(n,t));if(e&&typeof e=="object"){const n={};for(const[s,i]of Object.entries(e))typeof i=="string"&&i.includes("{{")?n[s]=i.replace(/\{\{\s*props\.([\w.]+)\s*\}\}/g,(r,o)=>{let l=t;for(const c of o.split("."))l=l==null?void 0:l[c];return l==null?"":String(l)}):n[s]=Ea(i,t);return n}return e}const cm=m.memo(({api:e,c:t,componentKey:n})=>{const[s,i]=m.useState(!1),[r,o]=m.useState(""),l=m.useRef(null),c=m.useMemo(()=>(Array.isArray(t.options)?t.options:[]).map(d=>typeof d=="string"?{label:d,value:d}:{label:d.label||d.value,value:d.value||d.label}),[t.options]),h=e.sceneData[t.name||""]??"",a=c.find(g=>g.value===h),u=m.useMemo(()=>{if(!r)return c;const g=r.toLowerCase();return c.filter(d=>d.label.toLowerCase().includes(g))},[c,r]),f=t.custom&&r&&!c.find(g=>g.value===r||g.label===r);m.useEffect(()=>{if(!s){o("");return}const g=d=>{l.current&&!l.current.contains(d.target)&&i(!1)};return setTimeout(()=>document.addEventListener("mousedown",g),0),()=>document.removeEventListener("mousedown",g)},[s]);const p=g=>{e.setSceneData(d=>({...d,[t.name||""]:g})),i(!1)};return E("div",{key:n,ref:l,style:{position:"relative",width:"100%"}},t.label&&E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("button",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 8px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontSize:"14px",textAlign:"left",gap:"8px"},onClick:()=>i(!s)},E("span",null,a?a.label:t.placeholder||"Select..."),E("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},E("path",{d:"m6 9 6 6 6-6"}))),s&&E("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,marginTop:"4px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:e.cfg.colors.surface,overflow:"hidden",maxHeight:"260px",display:"flex",flexDirection:"column"}},t.searchable!==!1&&E("input",{style:{width:"100%",padding:"8px",border:"none",borderBottom:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.text,outline:"none",fontSize:"13px"},placeholder:"Search...",value:r,onChange:g=>{o(g.target.value),g.stopPropagation()},onClick:g=>g.stopPropagation()}),E("div",{style:{overflow:"auto",flex:1}},u.map(g=>E("button",{key:g.value,style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",background:g.value===h?"rgba(59,130,246,0.2)":"transparent",color:g.value===h?e.cfg.colors.primary:e.cfg.colors.text,cursor:"pointer",fontSize:"13px"},onMouseEnter:d=>{d.currentTarget.style.background=e.cfg.colors.surfaceHover},onMouseLeave:d=>{d.currentTarget.style.background=g.value===h?"rgba(59,130,246,0.2)":"transparent"},onClick:()=>p(g.value)},g.label)),f&&E("button",{style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",borderTop:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.primary,cursor:"pointer",fontSize:"13px",fontStyle:"italic"},onClick:()=>p(r)},`+ Add "${r}"`))))});function I1(e,t,n){return m.createElement(cm,{api:e,c:t,componentKey:n})}const En={},D1=m.memo(({api:e,field:t,fieldName:n,fieldKey:s,fieldStyle:i,fieldWrapperStyle:r})=>{const[o,l]=m.useState([]);m.useEffect(()=>{t.dataSource&&(async()=>{var a;try{const u=e.interpolateText(t.dataSource),f=(a=e.selectDynamicOptions)==null?void 0:a[u];if(f&&f.length>0){l(f);return}En[u]||(En[u]=(async()=>{var g;try{const d=await fetch(u,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!d.ok)return[];const w=await d.json(),C=t.dataField||"configs",x=t.optionLabel||"label",k=t.optionValue||"value",S=w[C]||w.data||w,T=Array.isArray(S)?S.map(P=>({label:P[x]||P.name||P.label,value:P[k]||P.id||P.name||P.label})):[];return(g=e.setSelectDynamicOptions)==null||g.call(e,P=>({...P,[u]:T})),T}catch{return delete En[u],[]}})());const p=await En[u];p.length>0&&l(p)}catch{}})()},[t.dataSource]);const c=o.length>0?o:Array.isArray(t.options)?t.options:[],h=t.placeholder||t.label||"Select...";return m.createElement("div",{key:s,style:r||{width:"100%"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,E("select",{name:n,value:e.sceneData[n]??"",required:t.required,className:t.className,style:{...i,fontSize:"0.875rem"},size:"md",onChange:a=>e.setSceneData(u=>({...u,[n]:a.target.value}))},E("option",{key:"__placeholder",value:"",disabled:!0,hidden:!0},h),c.map((a,u)=>E("option",{key:u,value:typeof a=="string"?a:a.value},typeof a=="string"?a:a.label))))});function L1(e,t,n){var c;const s=t.className||"",i=((c=e.parseClassNameResponsive)==null?void 0:c.call(e,s,n))??e.parseClassName(s),r=e.getCommonProps(n,i,t),o=Array.isArray(t.fields)?t.fields:[],l=t.submitButton;return t.collection&&e.fetchEntitySchema?m.createElement(z1,{api:e,c:t,componentKey:n,formClassName:s,parsedStyle:i,formProps:r,fields:o,submitBtn:l}):hm(e,t,n,s,i,r,o,l)}function z1({api:e,c:t,componentKey:n,formClassName:s,parsedStyle:i,formProps:r,fields:o,submitBtn:l}){const[c,h]=m.useState(o),[a,u]=m.useState(!0);return m.useEffect(()=>{if(!e.fetchEntitySchema){u(!1);return}e.fetchEntitySchema(t.collection).then(f=>{if(!Array.isArray(f==null?void 0:f.fields)){u(!1);return}const p=new Map(f.fields.map(d=>[d.name,d])),g=o.map(d=>{var C;const w=p.get(d.name||((C=d.label)==null?void 0:C.toLowerCase()));return w?{...d,required:d.required??w.required,validation:d.validation??(w.validation?{...w.validation}:void 0),placeholder:d.placeholder??w.placeholder}:d});h(g),u(!1)}).catch(()=>u(!1))},[t.collection]),a?E("div",{key:n,style:{padding:"1rem",textAlign:"center",color:e.cfg.colors.textMuted,fontSize:"0.8rem"}},"Loading fields..."):hm(e,t,n,s,i,r,c,l)}const F1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,inputType:o,label:l,fieldStyle:c,onKeyDown:h}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const a=m.useRef(s);a.current=s;const u=m.useRef(c);u.current=c;const f=m.useCallback(g=>{a.current(g.target.value)},[]),p=m.createElement("input",{name:t,placeholder:i,required:r,type:o||"text",value:n??"",onChange:f,onKeyDown:h?g=>{g.key==="Enter"&&h()}:void 0,style:u.current});return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:c.color,marginBottom:"0.75rem"}},l),p):p}),B1=m.memo(function({api:t,field:n,fieldName:s,label:i,fieldStyle:r}){const o=m.useRef(null),[l,c]=m.useState(!1),h=t.sceneData[s]||"",a=t.sceneData[s+"_name"]||"",u=async f=>{var g,d,w,C;const p=(g=f.target.files)==null?void 0:g[0];if(f.target.value="",!!p){c(!0);try{const x=(d=t.showToast)==null?void 0:d.call(t,"Uploading test case (0%)…","success",0),k=t.uploadFile?await t.uploadFile(p,n.upload,S=>{var T;return(T=x==null?void 0:x.update)==null?void 0:T.call(x,`Uploading test case (${S}%)`)}):"";if((w=x==null?void 0:x.dismiss)==null||w.call(x),!k)throw new Error;t.setSceneData(S=>({...S,[s]:k,[s+"_name"]:p.name}))}catch{(C=t.showToast)==null||C.call(t,"Upload failed","error")}finally{c(!1)}}};return m.createElement("div",{style:{width:"100%"}},i&&E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:t.cfg.colors.textSecondary,marginBottom:"0.75rem"}},i),h?m.createElement("div",{style:{...r,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}},E("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"📎 "+(a||"Test case uploaded")),E("button",{type:"button",style:{background:"none",border:"none",cursor:"pointer",color:t.cfg.colors.danger,fontSize:"13px"},onClick:()=>t.setSceneData(f=>{const p={...f};return delete p[s],delete p[s+"_name"],p})},"Remove")):m.createElement("button",{type:"button",onClick:()=>{var f;return(f=o.current)==null?void 0:f.click()},style:{...r,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",cursor:"pointer",color:t.cfg.colors.textMuted,fontSize:"14px"}},l?"Uploading…":"⬆ Upload a test case"),E("input",{key:"file-input",ref:o,type:"file",accept:n.accept||".pdf,.docx,.txt,.md,.csv,.json",style:{display:"none"},onChange:u}))}),W1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,options:o,label:l,fieldStyle:c}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const h=m.useRef(s);h.current=s;const a=m.useRef(c);a.current=c;const u=m.useCallback(p=>{h.current(p.target.value)},[]),f=m.createElement("select",{name:t,required:r,value:n??"",onChange:u,style:{...a.current,cursor:"pointer",appearance:"none"}},i?m.createElement("option",{key:"__placeholder",value:""},i):null,...o.map((p,g)=>m.createElement("option",{key:g,value:typeof p=="string"?p:p.value},typeof p=="string"?p:p.label)));return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},l),f):f}),j1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,rows:o,label:l,fieldStyle:c}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const h=m.useRef(s);h.current=s;const a=m.useRef(c);a.current=c;const u=m.useCallback(p=>{h.current(p.target.value)},[]),f=m.createElement("textarea",{name:t,placeholder:i,required:r,rows:o||4,value:n??"",onChange:u,style:{...a.current,resize:"vertical",fontFamily:"inherit"}});return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},l),f):f});function hm(e,t,n,s,i,r,o,l){var h,a;const c=[];if(o.forEach((u,f)=>{var x;const p=`${n}-field-${f}`,g=u.name||((x=u.label)==null?void 0:x.toLowerCase())||"",d={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:u.borderless?u.backgroundColor||"transparent":e.cfg.colors.surface,color:u.textColor||e.cfg.colors.text,colorScheme:e.cfg.colorMode==="light"?"light":"dark",border:u.borderless?"none":`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},w={width:"100%",marginBottom:"1rem"},C=k=>k.value?e.interpolateText(String(k.value)):"";if(u.type==="richtext")c.push(m.createElement(P1,{key:p,api:e,field:u,fieldName:g,value:e.sceneData[g]??C(u),onChange:k=>e.setSceneData(S=>({...S,[g]:k}))}));else if(u.type==="textarea"){const k=u.rows||4;c.push(m.createElement(j1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label,required:u.required,rows:k,label:u.label,fieldStyle:d}))}else if(u.type==="select")if(u.dataSource)c.push(m.createElement(D1,{key:p,api:e,field:u,fieldName:g,fieldKey:p,fieldStyle:d,fieldWrapperStyle:w}));else{const k=Array.isArray(u.options)?u.options:[];c.push(m.createElement(W1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label||"Select...",required:u.required,options:k,label:u.label,fieldStyle:d}))}else if(u.type==="advanced-select")c.push(m.createElement("div",{key:`${p}-wrap`,style:w},m.createElement(cm,{key:p,api:e,c:{...u,name:g,options:u.options},componentKey:p})));else if(u.type==="file")c.push(m.createElement("div",{key:`${p}-wrap`,style:w},m.createElement(B1,{key:p,api:e,field:u,fieldName:g,label:u.label,fieldStyle:d})));else if(u.tags)c.push(m.createElement(V1,{key:p,api:e,field:u,value:e.sceneData[g]??C(u),onChange:k=>e.setSceneData(S=>({...S,[g]:k}))}));else{const k=u.type==="email"?"email":u.type==="password"?"password":u.type==="number"?"number":u.type==="date"?"date":"text";c.push(m.createElement(F1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label,required:u.required,inputType:k,label:u.label,fieldStyle:d,onKeyDown:u.onKeyDown?()=>e.handleButtonClick(u.onKeyDown):void 0}))}}),l){const u={padding:"0.75rem 1.5rem",borderRadius:e.cfg.components.inputRadius,cursor:"pointer",fontWeight:600,width:"100%",marginTop:"1rem"},f=l.className?((h=e.parseClassNameResponsive)==null?void 0:h.call(e,l.className,`${n}-submit`))??e.parseClassName(l.className):{},p=!!l.className&&/(^|\s)bg-[^\s]+/.test(l.className),g=!!l.className&&/(^|\s)text-[^\s]+/.test(l.className),d={...u,...f,...!p&&{backgroundColor:e.cfg.colors.primary},...!g&&{color:"#fff",border:"none"}},w=`${n}-submit`,C=!!((a=e.buttonLoading)!=null&&a[w]),x=()=>{var L,O,H,U,q;const P=[],I=e.sceneData||{};for(const X of o){const j=X.name||((L=X.label)==null?void 0:L.toLowerCase()),D=I[j],V=X.label||j;if(X.required&&(D==null||String(D).trim()==="")){P.push(`${V} is required`);continue}D==null||String(D).trim()===""||((O=X.validation)!=null&&O.pattern&&!new RegExp(X.validation.pattern).test(String(D))&&P.push(`${V} is invalid`),((H=X.validation)==null?void 0:H.min)!==void 0&&Number(D)<Number(X.validation.min)&&P.push(`${V} must be at least ${X.validation.min}`),((U=X.validation)==null?void 0:U.max)!==void 0&&Number(D)>Number(X.validation.max)&&P.push(`${V} must be at most ${X.validation.max}`),((q=X.validation)==null?void 0:q.minLength)!==void 0&&String(D).length<Number(X.validation.minLength)&&P.push(`${V} must be at least ${X.validation.minLength} characters`))}return P},k=()=>{var O,H;const P=x();if(P.length){(O=e.showToast)==null||O.call(e,P,"error");return}const I=()=>l.onClick?e.handleButtonClick(l.onClick,{onSuccess:l.onSuccess,onError:l.onError},{optimistic:l.optimistic,feedback:l.feedback}):Promise.resolve(),L=e.withLoading?e.withLoading(w,I):I();(H=L==null?void 0:L.catch)==null||H.call(L,()=>{})},S=l.onClick?()=>k():void 0,T=[];C?T.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{display:"inline-flex",width:"14px",height:"14px",marginRight:"6px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):l.icon&&T.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(l.icon,l.iconSize||16))),T.push(E("span",{key:"text"},l.text||"Submit")),c.push(E("button",{key:w,type:l.type||"submit",className:l.className,...e.getCommonProps(w,d,l),disabled:C||void 0,onClick:S},...T))}return E("form",{key:n,className:s,...r,onSubmit:u=>u.preventDefault()},...c)}const V1=m.memo(({api:e,field:t,value:n,onChange:s})=>{m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const i=m.useRef(null),r=(n||"").split(",").filter(Boolean).map(p=>p.trim()),[o,l]=m.useState(""),[c,h]=m.useState(!1),a=p=>{const g=p.target.value;if(g.includes(",")||g.includes(";")){const d=g.split(/[,;]+/).map(w=>w.trim()).filter(Boolean);if(d.length>0){const w=[...new Set([...r,...d])].join(", ");s(w)}l("")}else l(g)},u=p=>{if(p.key==="Enter"||p.key===","||p.key===";"){p.preventDefault();const g=o.trim();g&&(s([...new Set([...r,g])].join(", ")),l(""))}else p.key==="Backspace"&&!o&&r.length>0&&s(r.slice(0,-1).join(", "))},f=()=>{const p=o.trim();p&&(s([...new Set([...r,p])].join(", ")),l(""))};return E("div",{key:"tags",style:{width:"100%",marginBottom:"1rem"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,E("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",padding:"0.5rem 0.75rem",borderRadius:e.cfg.components.inputRadius||"8px",backgroundColor:e.cfg.colors.surface,border:`1px solid ${c?e.cfg.colors.primary:e.cfg.colors.border}`,cursor:"text",outline:"none",transition:"border-color 0.2s"},onClick:()=>{var p;return(p=i.current)==null?void 0:p.focus()}},...r.map((p,g)=>E("span",{key:g,style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",backgroundColor:e.cfg.colors.background,border:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.text,fontSize:"13px",lineHeight:"1.4"}},E("span",null,p),E("button",{type:"button",onMouseDown:d=>{d.preventDefault(),d.stopPropagation(),s(r.filter((w,C)=>C!==g).join(", "))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"0",fontSize:"14px",lineHeight:"1",display:"flex",alignItems:"center",fontFamily:"inherit"}},"×"))),E("input",{ref:i,type:"text",value:o,onChange:a,onKeyDown:u,onFocus:()=>h(!0),onBlur:()=>{h(!1),f()},placeholder:t.placeholder||(r.length>0?"":"Add email..."),style:{flex:1,minWidth:"100px",border:"none",outline:"none",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"14px",fontFamily:"inherit",padding:"2px 0"}})))});function O1(e,t,n){const s=e.interpolateText(t.text||t.content||"");if(!s)return null;const i=d=>{const w=[],C=/(\*\*(.+?)\*\*)|(\*(.+?)\*)|(`(.+?)`)|(\[(.+?)\]\((.+?)\))|(~~(.+?)~~)/g;let x=0,k;for(;(k=C.exec(d))!==null;)k.index>x&&w.push(d.slice(x,k.index)),k[2]?w.push(E("strong",{key:w.length},k[2])):k[4]?w.push(E("em",{key:w.length},k[4])):k[6]?w.push(E("code",{key:w.length},k[6])):k[8]?w.push(E("a",{key:w.length,href:k[9],target:"_blank",rel:"noopener noreferrer"},k[8])):k[11]&&w.push(E("del",{key:w.length},k[11])),x=k.index+k[0].length;return x<d.length&&w.push(d.slice(x)),w},r=s.split(`
|
|
16
16
|
`),o=[];let l=null,c=!1,h=[];const a=d=>{l&&(o.push(m.createElement(l.type,{key:d,style:{paddingLeft:"1.5rem",margin:"0.5rem 0"}},l.items.map((w,C)=>E("li",{key:`${d}-${C}`},w)))),l=null)},u=d=>{if(h.length===0)return;const w=h.join(`
|
|
17
|
-
`);o.push(E("div",{key:d,style:{position:"relative",background:"#1e1e2e",borderRadius:"8px",margin:"0.5rem 0"}},E("button",{style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",color:"#666",cursor:"pointer",padding:"4px",borderRadius:"4px",lineHeight:"1",zIndex:1,display:"inline-flex",alignItems:"center",fontSize:"14px"},onClick:C=>{C.preventDefault(),C.stopPropagation(),(k=>{navigator.clipboard.writeText(k).catch(()=>{const S=document.createElement("textarea");S.value=k,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select(),document.execCommand("copy"),document.body.removeChild(S)})})(w)}},E("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},E("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),E("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))),E("pre",{style:{padding:"16px 12px",margin:0,overflow:"auto",fontSize:"13px",lineHeight:"1.5",color:"#e2e8f0"}},E("code",null,w)))),h=[]};for(let d=0;d<r.length;d++){const w=r[d],C=w.trim();if(C==="```"){c?(u(`code-${d}`),c=!1):(a(`list-${d}`),c=!0,h=[]);continue}if(c){h.push(w);continue}if(!C){a(`list-${d}`);continue}const x=C.match(/^(#{1,3})\s+(.+)/);if(x){a(`list-${d}`);const T=`h${x[1].length}`;o.push(m.createElement(T,{key:d,style:{margin:"0.75rem 0 0.25rem"}},...i(x[2])));continue}if(C.startsWith("- ")||C.startsWith("* ")){const S=C.slice(2);l?l.type!=="ul"&&(a(`list-${d}`),l={type:"ul",items:[]}):l={type:"ul",items:[]},l.items.push(m.createElement(m.Fragment,{},...i(S)));continue}const k=C.match(/^\d+\.\s+(.+)/);if(k){l?l.type!=="ol"&&(a(`list-${d}`),l={type:"ol",items:[]}):l={type:"ol",items:[]},l.items.push(m.createElement(m.Fragment,{},...i(k[1])));continue}a(`list-${d}`),o.push(E("p",{key:d,style:{margin:"0.25rem 0"}},...i(C)))}c&&u("code-end"),a("list-end");const f={};t.fontSize!==void 0&&(f.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(f.fontWeight=t.fontWeight),t.color!==void 0&&(f.color=t.color),t.textAlign!==void 0&&(f.textAlign=t.textAlign);const p=t.className?{...f,...e.parseClassName(t.className)}:f,g=e.getCommonProps(n,p,t);return E("div",{key:n,...g},...o)}function V1(e,t,n){const s=e.cfg.colors,i={position:"relative",marginTop:"auto",bottom:0,left:0,right:0,zIndex:40,display:"flex",justifyContent:"space-around",alignItems:"stretch",backgroundColor:s.surfaceHover,borderTop:`1px solid ${s.border}`,padding:"6px 0",boxShadow:"0 -2px 8px rgba(0,0,0,0.08)"},o=(Array.isArray(t.items)?t.items:[]).map((c,h)=>{const a=c.active||!1,u=()=>{const f=()=>e.handleButtonClick(c.onClick||"");(e.withLoading?e.withLoading(`${n}-bn-${h}`,f):f()).catch(()=>{})};return E("button",{key:`${n}-bn-${h}`,onClick:u,style:{background:"none",border:"none",cursor:"pointer",flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:2,padding:"6px 0",color:a?s.primary:s.textMuted,fontSize:11,fontFamily:"inherit"},"aria-label":c.label||c.icon||"nav item"},c.icon?e.renderIcon(c.icon,20):null,c.label?E("span",{},c.label):null)}),l=e.getCommonProps(n,i,t);return E("div",{key:n,...l},...o)}function j1(e,t,n){const s=Array.isArray(t.panes)?t.panes:[],i=t.className?{display:"flex",flexDirection:"row",alignItems:"stretch",...e.parseClassName(t.className)}:{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%",flex:1,minHeight:0},r=s.map((l,c)=>{const a={width:l.width!==void 0?l.width:c===s.length-1?"1fr":"50%",minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},u=`${n}-split-${c}`;return E("div",{key:u,style:a},l.component?e.renderComponent(l.component,c,`${n}-split`):null)}),o=e.getCommonProps(n,i,t);return E("div",{key:n,...o},...r)}function O1(e,t,n){const s=e.cfg.colorMode!=="light",i=()=>{var l;return(l=e.setColorMode)==null?void 0:l.call(e,s?"light":"dark")},r=t.className?e.parseClassName(t.className):{background:"none",border:`1px solid ${e.cfg.colors.border}`,borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:6,padding:"6px 10px",color:e.cfg.colors.text,fontSize:14,fontFamily:"inherit"},o=e.getCommonProps(n,r,t);return E("button",{key:n,...o,onClick:i,"aria-label":s?"Switch to light mode":"Switch to dark mode"},E("span",{},s?"☀️":"🌙"),t.text?E("span",{},t.text):null)}function U1(e){var r;const{api:t,config:n}=e,s=t.interpolateText(n.channel||""),i=t.interpolateText(n.entityId||"");return m.useEffect(()=>{var w;const o=t.sdk;if(!t.isAuthenticated||!((w=o==null?void 0:o.client)!=null&&w.createWebSocket)||!s)return;let l=null,c=null,h=[],a=!1,u=null;const f=()=>{const C=t.interpolateText(n.resolution||"")||"",x=String(C).match(/(\d+)\s*x\s*(\d+)/);return x?{width:Number(x[1]),height:Number(x[2])}:{width:Number(t.interpolateText(n.width))||1280,height:Number(t.interpolateText(n.height))||720}},p=Number(t.interpolateText(n.fps))||10,g=async()=>{var x;if(a)return;a=!0,c&&c.state!=="inactive"&&await new Promise(k=>{c.onstop=()=>k(),c.stop()}),(x=l==null?void 0:l.close)==null||x.call(l);const C=new Blob(h,{type:"video/webm"});if(h=[],C.size!==0)try{const k=t.interpolateText(n.entityId||"")||"cast",S=t.interpolateText(n.fileName||"")||`${n.entityType||"video"}-${k}.webm`,T=new File([C],S,{type:"video/webm"}),P=await o.files.upload(T,{bucket:n.bucket||"backflow-storage",entityType:n.entityType||"video",entityId:k});t.setSceneData(I=>({...I,sessionId:k,[n.assetField||"asset_id"]:P==null?void 0:P.id,_recorded:P})),n.onRecorded&&t.handleButtonClick(String(n.onRecorded),{})}catch(k){Br("[recorder] upload failed:",k)}},d=()=>{if(c)return;const{width:C,height:x}=f(),k=document.createElement("canvas");k.width=C,k.height=x;const S=k.getContext("2d");if(S){u=T=>{const P=new Image;P.onload=()=>S.drawImage(P,0,0,C,x),P.src=T};try{const T=k.captureStream(p);c=new MediaRecorder(T,{mimeType:"video/webm",videoBitsPerSecond:5e6}),c.ondataavailable=P=>{P.data.size&&h.push(P.data)},c.start(500)}catch(T){Br("[recorder] start failed:",T),c=null}}};return l=o.client.createWebSocket(s),l.onmessage=C=>{let x=C==null?void 0:C.data;if(typeof x=="string")try{x=JSON.parse(x)}catch{return}(x==null?void 0:x.type)==="screencast_frame"&&x.frame?(d(),u==null||u(x.frame)):((x==null?void 0:x.status)==="completed"||(x==null?void 0:x.status)==="failed"||(x==null?void 0:x.type)==="workflow_completed"||(x==null?void 0:x.type)==="workflow_failed")&&g()},l.onclose=()=>g(),l.onerror=()=>g(),()=>{var C,x;a=!0,(C=c==null?void 0:c.stop)==null||C.call(c),(x=l==null?void 0:l.close)==null||x.call(l)}},[t.isAuthenticated,s,i,(r=e.config)==null?void 0:r.channel]),null}function H1(e){const{api:t,config:n,componentKey:s}=e,i=t.interpolateText(n.channel||""),r=m.useRef(null),o=m.useRef(null),[l,c]=m.useState(!1);m.useEffect(()=>{const a=()=>c(document.fullscreenElement===r.current);return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[]);const h=async a=>{var f,p;a.preventDefault(),a.stopPropagation();const u=r.current;if(u){if(document.fullscreenElement){await((f=document.exitFullscreen)==null?void 0:f.call(document));return}await((p=u.requestFullscreen)==null?void 0:p.call(u))}};return m.useEffect(()=>{var d;const a=t.sdk;if(!t.isAuthenticated||!((d=a==null?void 0:a.client)!=null&&d.createWebSocket)||!i)return;let u=null,f=!1;const p=w=>{const C=o.current;if(!C)return;const x=new Image;x.onload=()=>{if(f)return;const k=C.getContext("2d");k&&(C.width=x.width,C.height=x.height,k.drawImage(x,0,0,C.width,C.height))},x.src=w},g=()=>{f||(u=a.client.createWebSocket(i),u.onmessage=w=>{let C=w==null?void 0:w.data;if(typeof C=="string")try{C=JSON.parse(C)}catch{return}(C==null?void 0:C.type)==="screencast_frame"&&C.frame&&p(C.frame)},u.onclose=()=>{f||setTimeout(g,3e3)},u.onerror=()=>{var w;(w=u==null?void 0:u.close)==null||w.call(u)})};return g(),()=>{var w;f=!0,(w=u==null?void 0:u.close)==null||w.call(u)}},[t.isAuthenticated,i,s]),m.createElement("div",{key:s,ref:r,className:"relative w-full h-full bg-black group",style:{width:"100%",height:"100%"}},m.createElement("canvas",{ref:o,className:t.parseClassName(n.className||"w-full h-full object-contain bg-black [aspect-ratio:16/9]"),style:{width:"100%",height:"100%",objectFit:"contain"}}),n.fullscreen===!1?null:m.createElement("button",{type:"button",onClick:h,title:l?"Exit fullscreen":"Open fullscreen","aria-label":l?"Exit fullscreen":"Open fullscreen",className:"absolute top-2 right-2 z-20 inline-flex h-8 w-8 items-center justify-center rounded-full bg-black/55 text-white transition-opacity hover:bg-black/75"},t.renderIcon(l?"minimize-2":"maximize-2",16)))}function js(e,t,n,s,i){if(!Array.isArray(t)||t.length===0)return null;if(s==="row")return t.map((h,a)=>e.renderComponent(h,a,n));const r=[];let o=[];const l=h=>h&&(h.type==="button"||i&&(h.type==="link"||h.type==="a")),c=h=>{o.length!==0&&(o.length===1?r.push(e.renderComponent(o[0],h,n)):r.push(E("div",{key:`${n}-btns-${h}`,style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:"0.75rem"}},...o.map((a,u)=>e.renderComponent(a,h+u,n)))),o=[])};return t.forEach((h,a)=>{l(h)?o.push(h):(c(a),r.push(e.renderComponent(h,a,n)))}),c(t.length),r}function hm(e){return e.className?/\bhidden\b/.test(e.className)&&/\b(sm|md|lg|xl):(?:block|flex|inline|inline-block|inline-flex)\b/.test(e.className):!1}function um(e){return e.children?e.children.filter(t=>hm(t)):[]}function q1(e){return e.children?e.children.filter(t=>!hm(t)):[]}function dm(e){var t;return Array.isArray((t=e==null?void 0:e.mobileMenu)==null?void 0:t.items)?e.mobileMenu.items:[]}function G1(e){if(!(e.layout==="row"||e.className&&/\bflex-row\b/.test(e.className)))return!1;const n=um(e),s=dm(e);if(n.length===0&&s.length===0)return!1;const i=["text","link","button","accordion"];if(!(n.length===0||n.every(c=>i.includes(c.type))))return!1;const o=e.className||"";return/\b(sticky|fixed)\b/.test(o)||/\btop-0\b/.test(o)||/\bz-(10|20|30|40|50)\b/.test(o)||/\bjustify-between\b/.test(o)||e.justify==="space-between"}function Pu(e){const t=dm(e);return t.length>0?t:um(e)}function _u(e){return q1(e)}function $u(e,t){return m.createElement("button",{key:"hamburger-icon",onClick:()=>t(!e),style:{background:"none",border:"none",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",color:"inherit",fontSize:"24px",lineHeight:1},"aria-label":e?"Close menu":"Open menu"},e?"✕":"☰")}function fm(e){return e=String(e??""),e.replace(/\bhidden\b/g,"").replace(/\b(sm|md|lg|xl|2xl):(block|flex|inline|inline-block|inline-flex)\b/g,"").replace(/\s+/g," ").trim()}function Nu(e){const t=(e==null?void 0:e.className)||"";return/\bdrawer\b/.test(t)&&!/\bdrawer-(item|item-[a-z]+)\b/.test(t)}function Es(e){return/\bburger-first\b/.test((e==null?void 0:e.className)||"")}function Iu({navLinks:e,parentKey:t,renderComponentFn:n,open:s,onClose:i,colorMode:r,portalTarget:o,mobileMenu:l,parseMenuClassName:c}){const[h,a]=m.useState(s);if(m.useEffect(()=>{s&&a(!0)},[s]),!s&&!h)return null;const u=e.map(C=>({...C,className:C.className?fm(C.className):void 0})),f=r!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",p=l!=null&&l.className&&c?c(l.className,`${t}-side-drawer-class`):{},g=l!=null&&l.headerClassName&&c?c(l.headerClassName,`${t}-side-header-class`):{},d=()=>{a(!1),i()},w=m.createElement(m.Fragment,null,m.createElement("div",{key:`${t}-side-backdrop`,onClick:d,style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.45)",zIndex:90,opacity:s?1:0,transition:"opacity 0.25s ease",pointerEvents:s?"auto":"none"}}),m.createElement("div",{key:`${t}-side-drawer`,className:l==null?void 0:l.className,style:{position:"absolute",top:0,bottom:0,left:0,width:"min(300px, 85%)",backgroundColor:f,zIndex:100,overflowY:"auto",transform:s?"translateX(0)":"translateX(-100%)",transition:"transform 0.25s ease",boxShadow:"2px 0 12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",gap:"4px",padding:"16px 12px",...p}},m.createElement("div",{key:`${t}-side-header`,className:l==null?void 0:l.headerClassName,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px 12px",borderBottom:"1px solid rgba(128, 128, 128, 0.2)",marginBottom:"8px",fontSize:18,fontWeight:700,...g}},(l==null?void 0:l.title)||"Menu",m.createElement("button",{onClick:d,"aria-label":"Close menu",style:{background:"none",border:"none",cursor:"pointer",fontSize:22,color:"inherit",lineHeight:1}},"✕")),u.map((C,x)=>m.createElement(mm,{key:`${t}-drawer-item-${x}`,link:C,idx:x,parentKey:t,renderComponentFn:n,onClose:d,itemClassName:l==null?void 0:l.itemClassName,itemStyle:l!=null&&l.itemClassName&&c?c(l.itemClassName,`${t}-drawer-item-class-${x}`):void 0}))));return o?Wu.createPortal(w,o):w}function mm({link:e,idx:t,parentKey:n,renderComponentFn:s,onClose:i,itemClassName:r,itemStyle:o}){const[l,c]=m.useState(!1),h=e.type==="link"||e.type==="button";return m.createElement("div",{key:`${n}-drawer-item-${t}`,className:r,style:{display:"flex",flexDirection:"row",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",borderRadius:8,cursor:h?"pointer":"default",backgroundColor:l?"rgba(128, 128, 128, 0.12)":"transparent",transition:"background-color 0.15s ease",...o},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:()=>{h&&i()}},s(e,t+1,`${n}-drawer`))}function Du(e,t,n,s,i,r,o,l){if(!s)return null;const c=e.map(f=>({...f,className:f.className?fm(f.className):void 0})),h=i!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",a=i!=="light"?"rgba(75, 85, 99, 0.5)":"rgba(209, 213, 219, 0.5)",u=o!=null&&o.className&&l?l(o.className,`${t}-mobile-drawer-class`):{};return m.createElement("div",{key:`${t}-mobile-drawer`,className:o==null?void 0:o.className,style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:h,borderTop:`1px solid ${a}`,padding:"12px",display:"flex",flexDirection:"column",gap:"4px",zIndex:50,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",...u}},c.map((f,p)=>m.createElement(mm,{key:`${t}-drawer-item-${p}`,link:f,idx:p,parentKey:t,renderComponentFn:n,onClose:()=>r==null?void 0:r(!1),itemClassName:o==null?void 0:o.itemClassName,itemStyle:o!=null&&o.itemClassName&&l?l(o.itemClassName,`${t}-drawer-item-class-${p}`):void 0})))}function Y1(e,t,n){var o;if(t.className){const l=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className);if(l.display==null&&(l.display="flex"),l.flexDirection==null){const h=t.className||"",a=h.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(a)l.flexDirection=a[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(h)){const u=/\bmin-h-(screen|\[[^\]]+\])/.test(h)&&/\bitems-center\b/.test(h),f=Array.isArray(t.children)&&t.children.length>0&&t.children.every(p=>p&&["h1","h2","h3","h4","p","text"].includes(p.type));l.flexDirection=u||f?"column":"row"}else l.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const h=Fi(t.className);if(h.px.size>0){const u=ht(h.px,e.containerWidth,"0px");l.paddingLeft=u,l.paddingRight=u}if(h.py.size>0){const u=ht(h.py,e.containerWidth,"0px");l.paddingTop=u,l.paddingBottom=u}if(h.p.size>0){const u=ht(h.p,e.containerWidth,"0px");l.padding=u}const a=Gs(t.className);a.size>0&&(l.display=ht(a,e.containerWidth,"flex"))}const c=e.getCommonProps(n,l,t);return m.createElement("div",{key:n,className:t.className,...c},js(e,Array.isArray(t.children)?t.children:[],n,l.flexDirection))}const s=e.cfg.colorMode==="light",i={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"1rem",padding:"1.5rem",borderRadius:"1rem",backdropFilter:"blur(8px)",border:s?"1px solid rgba(0, 0, 0, 0.1)":"1px solid rgba(55, 65, 81, 0.5)"},r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...r},js(e,t.children,n,i.flexDirection))}function X1(e,t,n){var l;const s=e.isMobileView&&G1(t);if(t.className){const c=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(c.display==null&&(c.display="flex"),c.flexDirection==null){const u=t.className||"",f=u.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(f)c.flexDirection=f[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(u)){const p=/\bmin-h-(screen|\[[^\]]+\])/.test(u)&&/\bitems-center\b/.test(u),g=Array.isArray(t.children)&&t.children.length>0&&t.children.every(d=>d&&["h1","h2","h3","h4","p","text"].includes(d.type));c.flexDirection=p||g?"column":"row"}else c.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const u=Fi(t.className);if(u.px.size>0){const p=ht(u.px,e.containerWidth,"0px");c.paddingLeft=p,c.paddingRight=p}if(u.py.size>0){const p=ht(u.py,e.containerWidth,"0px");c.paddingTop=p,c.paddingBottom=p}if(u.p.size>0){const p=ht(u.p,e.containerWidth,"0px");c.padding=p}const f=Gs(t.className);f.size>0&&(c.display=ht(f,e.containerWidth,"flex"))}if(s&&t.children&&t.children.length>0){const u=_u(t),f=Pu(t);c.position="relative",c.display="flex",c.alignItems="center",c.justifyContent=Es(t)?"flex-start":"space-between",Es(t)&&(c.gap=10);const p=e.getCommonProps(n,c,t),g=$u(e.mobileMenuOpen,e.setMobileMenuOpen),d=(C,x)=>{var k;return((k=e.parseClassNameResponsive)==null?void 0:k.call(e,C,x))??e.parseClassName(C)},w=u.map((C,x)=>e.renderComponent(C,x,n));return m.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...p},...Es(t)?[g,...w]:[...w,g],Nu(t)?m.createElement(Iu,{navLinks:f,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:d}):Du(f,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,d))}const h=e.getCommonProps(n,c,t),a=t.onClick?{onClick:u=>{u.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return m.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...h,...a},js(e,Array.isArray(t.children)?t.children:[],n,c.flexDirection))}const i={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"16px"};if(t.align){const c={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};i.alignItems=c[t.align]}if(t.justify){const c={start:"flex-start",center:"center",end:"flex-end","space-between":"space-between"};i.justifyContent=c[t.justify]}if(t.padding!==void 0&&(i.padding=`${t.padding}px`),s&&t.children&&t.children.length>0){const c=_u(t),h=Pu(t);i.position="relative",i.display="flex",i.alignItems="center",i.justifyContent=Es(t)?"flex-start":"space-between",Es(t)&&(i.gap=10);const a=e.getCommonProps(n,i,t),u=$u(e.mobileMenuOpen,e.setMobileMenuOpen),f=(g,d)=>{var w;return((w=e.parseClassNameResponsive)==null?void 0:w.call(e,g,d))??e.parseClassName(g)},p=c.map((g,d)=>e.renderComponent(g,d,n));return m.createElement("div",{key:n,...a},...Es(t)?[u,...p]:[...p,u],Nu(t)?m.createElement(Iu,{navLinks:h,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:f}):Du(h,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,f))}const r=e.getCommonProps(n,i,t),o=t.onClick?{onClick:c=>{c.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return m.createElement("div",{key:n,...r,...o},js(e,t.children,n,i.flexDirection))}function Q1(e,t,n){var r,o;if(t.className){const l=((r=e.parseClassNameResponsive)==null?void 0:r.call(e,t.className,n))??e.parseClassName(t.className);let c;if(e.renderMode!=="css-driven"){const a=ov(t.className),u=a.size>0?av(a,e.containerWidth):void 0;c={display:"grid",...l,...u!==void 0&&{gridTemplateColumns:`repeat(${u}, minmax(0, 1fr))`}}}else c={display:"grid",...l};const h=e.getCommonProps(n,c,t);return m.createElement("div",{key:n,className:t.className,...h},(Array.isArray(t.children)?t.children:[]).map((a,u)=>e.renderComponent(a,u,n)))}const s={display:"grid",width:"100%",gridTemplateColumns:`repeat(${t.cols||2}, minmax(0, 1fr))`,gap:t.gap!==void 0?`${t.gap}px`:"16px"},i=e.getCommonProps(n,s,t);return m.createElement("div",{key:n,...i},(o=t.children)==null?void 0:o.map((l,c)=>e.renderComponent(l,c,n)))}function J1(e,t,n){var l,c;if(t.className){const a={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:e.containerWidth>0&&e.containerWidth<_i.md?"300px":"500px",gap:"24px"};(t.bg||t.backgroundColor)&&(a.background=t.bg||t.backgroundColor),t.bgImage&&(a.backgroundImage=`url(${t.bgImage})`,a.backgroundSize="cover",a.backgroundPosition="center");const u={...a,...((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className)};if(Array.isArray(t.children)&&t.children.some(g=>g.type==="grid")||(u.textAlign="center"),e.renderMode!=="css-driven"){const g=Fi(t.className);if(g.px.size>0){const d=ht(g.px,e.containerWidth,"0px");u.paddingLeft=d,u.paddingRight=d}if(g.py.size>0){const d=ht(g.py,e.containerWidth,"0px");u.paddingTop=d,u.paddingBottom=d}if(g.p.size>0){const d=ht(g.p,e.containerWidth,"0px");u.padding=d}}const p=e.getCommonProps(n,u,t);return m.createElement("div",{key:n,className:t.className,...p},js(e,Array.isArray(t.children)?t.children:[],n,u.flexDirection))}const s=e.containerWidth<_i.md,i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:s?"300px":"500px",padding:s?"1.5rem":"3rem",background:t.bg||t.backgroundColor,gap:"24px"};t.bgImage&&(i.backgroundImage=`url(${t.bgImage})`,i.backgroundSize="cover",i.backgroundPosition="center"),Array.isArray(t.children)&&t.children.some(h=>h.type==="grid")||(i.textAlign="center");const o=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...o},(c=t.children)==null?void 0:c.map((h,a)=>e.renderComponent(h,a,n)))}function K1(e,t,n){var o;const s={display:"flex",flexDirection:"row",alignItems:"center",width:"100%",flexShrink:0,position:"sticky",top:0,zIndex:50,gap:"1.25rem",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colors.surface,borderBottom:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(s,((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const l=Fi(t.className);l.px.size>0&&(s.paddingLeft=ht(l.px,e.containerWidth,"0px"),s.paddingRight=ht(l.px,e.containerWidth,"0px")),l.py.size>0&&(s.paddingTop=ht(l.py,e.containerWidth,"0px"),s.paddingBottom=ht(l.py,e.containerWidth,"0px"));const c=Gs(t.className);c.size>0&&(s.display=ht(c,e.containerWidth,"flex"))}const i=e.getCommonProps(n,s,t),r=t.className?{key:n,className:t.className,...i}:{key:n,...i};return m.createElement("header",r,(Array.isArray(t.children)?t.children:[]).filter(l=>Array.isArray(l.visibleOn)?l.visibleOn.includes(e.currentSceneId):Array.isArray(l.hiddenOn)?!l.hiddenOn.includes(e.currentSceneId):!0).map((l,c)=>e.renderComponent(l,c,n)))}function Z1(e,t,n){var c;const s={display:"flex",flexDirection:t.layout==="row"?"row":"column",width:"100%",flexShrink:0,marginTop:"auto",gap:"1rem",padding:"2.5rem 1.5rem",backgroundColor:e.cfg.colors.surfaceHover,borderTop:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(s,((c=e.parseClassNameResponsive)==null?void 0:c.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const h=Fi(t.className);h.px.size>0&&(s.paddingLeft=ht(h.px,e.containerWidth,"0px"),s.paddingRight=ht(h.px,e.containerWidth,"0px")),h.py.size>0&&(s.paddingTop=ht(h.py,e.containerWidth,"0px"),s.paddingBottom=ht(h.py,e.containerWidth,"0px"))}const i=e.getCommonProps(n,s,t),r=t.className?{key:n,className:t.className,...i}:{key:n,...i};let o=Array.isArray(t.children)?t.children:[];const l=o[0];return l&&l.type==="text"&&/^(\u00a9|\(c\)|copyright)/i.test(String(l.text).trim())&&(o=[...o.slice(1),l]),m.createElement("footer",r,js(e,o,n,s.flexDirection,!0))}const Lu=new Map;function tS(e){let t=Lu.get(e);return t||(t=Nr.create(e),Lu.set(e,t)),t}function lt(e,t){if(!(e!=null&&e.motion)||!m.isValidElement(t))return t;const n=t,s=n.props,i=tS(n.type);return m.createElement(i,{key:n.key,...s,initial:e.initial,animate:e.animate,exit:e.exit,transition:e.transition,variants:e.variants,whileHover:e.whileHover,whileTap:e.whileTap,whileFocus:e.whileFocus,whileInView:e.whileInView,layout:e.animateLayout},s==null?void 0:s.children)}function Cr(e,t,n,s=""){var o;const i=t,r=`${s}-${n}`;if(Array.isArray(i.hiddenOn)&&i.hiddenOn.includes(e.currentSceneId)||Array.isArray(i.visibleOn)&&!i.visibleOn.includes(e.currentSceneId)||i.condition&&e.evaluateCondition&&!e.evaluateCondition(i.condition))return null;if(!Array.isArray(i.children)&&Array.isArray(i.components)&&(i.children=i.components),i.type==="custom"){const l=i.tagName||"div",c=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,i.className||"",r))??(i.className?e.parseClassName(i.className):{});i.rawStyle&&Object.assign(c,i.rawStyle);const h=e.getCommonProps(r,c,i),a=Array.isArray(i.children)?i.children.map((f,p)=>e.renderComponent(f,p,r)):[],u=i.motion?{motion:i.motion,initial:i.initial,animate:i.animate,exit:i.exit,transition:i.transition,variants:i.variants,whileHover:i.whileHover,whileTap:i.whileTap,whileFocus:i.whileFocus,whileInView:i.whileInView,animateLayout:i.animateLayout}:{};return E(l,{key:r,className:i.className,...h,...u},...a)}if(/^h[1-6]$/.test(i.type)||i.type==="p"||i.type==="span"||i.type==="label"||i.type==="blockquote"||i.type==="strong"||i.type==="em"||i.type==="li"||i.type==="figcaption"||i.type==="th"||i.type==="td"||i.type==="heading"||i.type==="paragraph"||i.type==="address"||i.type==="time"||i.type==="legend"||i.type==="caption"?i.type="text":i.type==="div"||i.type==="article"||i.type==="aside"||i.type==="main"||i.type==="figure"?i.type=i.children?"section":"text":i.type==="a"?i.type="link":i.type==="img"?i.type="image":i.type==="ul"||i.type==="ol"?i.type="list":i.type==="table"||i.type==="thead"||i.type==="tbody"||i.type==="tfoot"||i.type==="tr"?i.type="table":i.type==="br"?i.type="spacer":i.type==="hr"?i.type="divider":i.type==="details"||i.type==="summary"?i.type=i.children?"section":"text":i.type==="nav"?i.type="section":(i.type==="form"&&!i.fields||i.type==="listItem")&&(i.type=i.children?"section":"text"),i.type==="select"&&Array.isArray(i.options)&&typeof i.options[0]=="string"&&(i.options=i.options.map(l=>({label:l,value:l}))),i.type==="dropdown-button"&&!i.items&&i.options&&(i.items=Array.isArray(i.options)&&typeof i.options[0]=="string"?i.options.map(l=>({label:l,value:l})):i.options),(i.type==="input"||i.type==="textarea")&&!i.placeholder&&i.label&&(i.placeholder=i.label),e.imageReplacements&&e.imageReplacements.size>0){const l=e.imageReplacements.get(r);if(l&&l.url){const c={width:"100%",height:"auto",maxHeight:"300px",objectFit:"cover",borderRadius:"0.75rem"},h=e.getCommonProps(r,c,i),a=i.motion?{motion:i.motion,initial:i.initial,animate:i.animate,whileHover:i.whileHover,whileTap:i.whileTap,transition:i.transition,animateLayout:i.animateLayout}:{};return E("img",{key:`${r}-${l.url}`,src:l.url,alt:l.name||"Replacement image",...h,...a})}}switch(i.type){case"text":return lt(i,Yw(e,i,r));case"html":return lt(i,Qw(e,i,r));case"link":return lt(i,Jw(e,i,r));case"button":return lt(i,Kw(e,i,r));case"image":return lt(i,Zw(e,i,r));case"input":return lt(i,t1(e,i,r));case"hidden":return lt(i,e1(e,i,r));case"select":return lt(i,n1(e,i,r));case"checkbox":return lt(i,s1(e,i,r));case"card":return lt(i,Y1(e,i,r));case"section":case"container":case"cta_section":return lt(i,X1(e,i,r));case"header":return lt(i,K1(e,i,r));case"grid":case"features_grid":return lt(i,Q1(e,i,r));case"hero":return lt(i,J1(e,i,r));case"footer":return lt(i,Z1(e,i,r));case"spacer":return lt(i,f1(e,i,r));case"divider":return lt(i,m1(e,i,r));case"list":return lt(i,hv(e,i,r));case"table":return lt(i,dv(e,i,r));case"badge":return lt(i,i1(e,i,r));case"tag":return lt(i,r1(e,i,r));case"avatar":return lt(i,o1(e,i,r));case"progress":return lt(i,a1(e,i,r));case"recorder":return m.createElement(U1,{api:e,config:i,key:r});case"live-cast":return m.createElement(H1,{api:e,config:i,componentKey:r,key:r});case"tabs":return lt(i,lv(e,i,r));case"accordion":return lt(i,cv(e,i,r));case"bottom_nav":return lt(i,V1(e,i,r));case"split":return lt(i,j1(e,i,r));case"theme_toggle":return lt(i,O1(e,i,r));case"slider":case"carousel":return lt(i,h1(e,i,r));case"marquee":return lt(i,u1(e,i,r));case"camera":case"capture":return lt(i,d1(e,i,r));case"phaser_game":return lt(i,e.renderPhaserGame?e.renderPhaserGame(i,r):null);case"search":return lt(i,l1(e,i,r));case"breadcrumb":return lt(i,c1(e,i,r));case"form":return lt(i,N1(e,i,r));case"textarea":return lt(i,g1(e,i,r));case"icon":return lt(i,y1(e,i,r));case"markdown":return lt(i,W1(e,i,r));case"dropdown-button":return lt(i,R1(e,i,r));case"widget":return lt(i,P1(e,i,r));case"advanced-select":return lt(i,_1(e,i,r));case"metric_display":return lt(i,b1(e,i,r));case"bar_chart":return lt(i,v1(e,i,r));case"line_chart":return lt(i,Go(e,i,r,!1));case"area_chart":return lt(i,Go(e,i,r,!0));case"candlestick":return lt(i,Go(e,i,r,!1,!0));case"fx_ticker":return lt(i,x1(e,i,r));case"trading_view":return lt(i,S1(e,i,r));case"loader":return lt(i,p1(e,i,r));case"flow_diagram":return lt(i,C1(e,i,r));case"flow":return lt(i,M1(e,i,r));default:return lt(i,E1(e,i,r))}}function pm(e){const t=new Map,n=new Map;for(const s of e)if(s.type==="render_scene"&&s.route){const i=s.route.startsWith("/")?s.route:`/${s.route}`;t.set(s.id,i),n.set(i,s.id)}for(const s of e)if(s.type==="render_scene"&&!t.has(s.id)){const i=`/${s.id}`;t.set(s.id,i),n.set(i,s.id)}return{sceneToRoute:t,routeToScene:n}}function Ta(e){if(typeof window>"u")return null;const t=window.location.hash;if(!t||t==="#")return null;const n=t.slice(1);return e.get(n)||null}function kr(e,t,n=!1){if(typeof window>"u")return;const s=t.get(e);if(!s)return;const i=`#${s}`;window.location.hash!==i&&(n?window.history.replaceState({sceneId:e},"",i):window.history.pushState({sceneId:e},"",i))}const eS=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1};async function Mr(e,t,n={},s){var i;try{const r=t.indexOf(".");if(r===-1)throw new Error(`Invalid SDK call syntax: ${t}`);const o=t.slice(0,r),l=t.slice(r+1),c=l.indexOf("(");if(c===-1)throw new Error(`Invalid SDK call syntax (missing parentheses): ${t}`);const h=l.slice(0,c),a=l.slice(c+1,-1),u=nS(a,n);let f=e[o];if(!f)throw new Error(`Unknown SDK resource: ${String(o)}`);const p=h.split(".");for(let w=0;w<p.length-1;w++){const C=p[w];if(C&&(f=f[C],!f))throw new Error(`Unknown path ${p.slice(0,w+1).join(".")} on resource ${String(o)}`)}const g=p[p.length-1],d=f[g];if(typeof d!="function")throw new Error(`Unknown method ${g} on ${String(o)}.${p.slice(0,-1).join(".")}`);return await d.apply(f,u)}catch(r){throw eS()&&console.error("[SDK Executor] Error:",r),(i=s==null?void 0:s.onError)==null||i.call(s,r),r}}function nS(e,t){if(!e.trim())return[];const s=e.replace(/\{\{([\w.]+)\}\}/g,(i,r)=>{if(r==="now")return JSON.stringify(new Date().toISOString());const o=iS(t,r);return o===void 0?"null":typeof o=="string"?`"${o}"`:JSON.stringify(o)}).replace(/([{,]\s*)([A-Za-z_$][\w$]*)\s*:/g,'$1"$2":').replace(/'((?:[^'\\]|\\.)*)'/g,(i,r)=>`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`);try{return JSON.parse(`[${s}]`)}catch{return sS(s).map(i=>{const r=i.trim();if(r.startsWith("'")&&r.endsWith("'")||r.startsWith('"')&&r.endsWith('"'))return r.slice(1,-1);if(!isNaN(Number(r)))return Number(r);if(r==="true")return!0;if(r==="false")return!1;if(r==="null")return null;try{return JSON.parse(r)}catch{return r}})}}function sS(e){const t=[];let n="",s=0,i=null;for(let r=0;r<e.length;r++){const o=e[r],l=e[r-1];if((o==='"'||o==="'")&&l!=="\\"&&(i===o?i=null:i||(i=o)),!i&&((o==="{"||o==="["||o==="(")&&s++,(o==="}"||o==="]"||o===")")&&s--,o===","&&s===0)){t.push(n),n="";continue}n+=o}return n.trim()&&t.push(n),t}function iS(e,t){const n=t.split(".");let s=e;for(const i of n){if(s==null)return;s=s[i]}return s}function Ci(e){return e.startsWith("sdk:")}function pi(e){return Ci(e)?e.slice(4):e}function rS(e,t,...n){const s=n.map(i=>typeof i=="string"?`'${i}'`:JSON.stringify(i)).join(", ");return`sdk:${e}.${t}(${s})`}function oS(e,t){const n=new Map,s=(i,r)=>{r.size>0&&n.set(i,r)};return s("--bf-fd",e.flexDirection),s("--bf-gap",e.gap),s("--bf-w",e.width),s("--bf-items",e.alignItems),s("--bf-justify",e.justifyContent),s("--bf-display",e.display),s("--bf-cols",e.gridCols),s("--bf-text",e.textSize),s("--bf-radius",e.borderRadius),e.padding.p.size>0&&s("--bf-p",e.padding.p),e.padding.px.size>0&&s("--bf-px",e.padding.px),e.padding.py.size>0&&s("--bf-py",e.padding.py),e.margin.all.size>0&&s("--bf-m",e.margin.all),e.margin.t.size>0&&s("--bf-mt",e.margin.t),e.margin.r.size>0&&s("--bf-mr",e.margin.r),e.margin.b.size>0&&s("--bf-mb",e.margin.b),e.margin.l.size>0&&s("--bf-ml",e.margin.l),e.margin.x.size>0&&s("--bf-mx",e.margin.x),e.margin.y.size>0&&s("--bf-my",e.margin.y),n}function aS(e,t){const n=String(t).replace(/[^a-zA-Z0-9_-]/g,"_");return`${e}-${n}`}function gm(e,t,n){const s=oS(n);if(s.size===0)return"";const i=`[data-bf-r="${e}-${t}"]`,r=[];for(const o of Af){if(o==="base")continue;const l=Tf[o],c=[];for(const[h,a]of s)a.has(o)&&(aS(h,t),c.push(` ${h.replace("--bf-","--bf-")}: ${a.get(o)};`));c.length>0&&r.push(`@media (min-width: ${l}px) {
|
|
17
|
+
`);o.push(E("div",{key:d,style:{position:"relative",background:"#1e1e2e",borderRadius:"8px",margin:"0.5rem 0"}},E("button",{style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",color:"#666",cursor:"pointer",padding:"4px",borderRadius:"4px",lineHeight:"1",zIndex:1,display:"inline-flex",alignItems:"center",fontSize:"14px"},onClick:C=>{C.preventDefault(),C.stopPropagation(),(k=>{navigator.clipboard.writeText(k).catch(()=>{const S=document.createElement("textarea");S.value=k,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select(),document.execCommand("copy"),document.body.removeChild(S)})})(w)}},E("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},E("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),E("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))),E("pre",{style:{padding:"16px 12px",margin:0,overflow:"auto",fontSize:"13px",lineHeight:"1.5",color:"#e2e8f0"}},E("code",null,w)))),h=[]};for(let d=0;d<r.length;d++){const w=r[d],C=w.trim();if(C==="```"){c?(u(`code-${d}`),c=!1):(a(`list-${d}`),c=!0,h=[]);continue}if(c){h.push(w);continue}if(!C){a(`list-${d}`);continue}const x=C.match(/^(#{1,3})\s+(.+)/);if(x){a(`list-${d}`);const T=`h${x[1].length}`;o.push(m.createElement(T,{key:d,style:{margin:"0.75rem 0 0.25rem"}},...i(x[2])));continue}if(C.startsWith("- ")||C.startsWith("* ")){const S=C.slice(2);l?l.type!=="ul"&&(a(`list-${d}`),l={type:"ul",items:[]}):l={type:"ul",items:[]},l.items.push(m.createElement(m.Fragment,{},...i(S)));continue}const k=C.match(/^\d+\.\s+(.+)/);if(k){l?l.type!=="ol"&&(a(`list-${d}`),l={type:"ol",items:[]}):l={type:"ol",items:[]},l.items.push(m.createElement(m.Fragment,{},...i(k[1])));continue}a(`list-${d}`),o.push(E("p",{key:d,style:{margin:"0.25rem 0"}},...i(C)))}c&&u("code-end"),a("list-end");const f={};t.fontSize!==void 0&&(f.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(f.fontWeight=t.fontWeight),t.color!==void 0&&(f.color=t.color),t.textAlign!==void 0&&(f.textAlign=t.textAlign);const p=t.className?{...f,...e.parseClassName(t.className)}:f,g=e.getCommonProps(n,p,t);return E("div",{key:n,...g},...o)}function U1(e,t,n){const s=e.cfg.colors,i={position:"relative",marginTop:"auto",bottom:0,left:0,right:0,zIndex:40,display:"flex",justifyContent:"space-around",alignItems:"stretch",backgroundColor:s.surfaceHover,borderTop:`1px solid ${s.border}`,padding:"6px 0",boxShadow:"0 -2px 8px rgba(0,0,0,0.08)"},o=(Array.isArray(t.items)?t.items:[]).map((c,h)=>{const a=c.active||!1,u=()=>{const f=()=>e.handleButtonClick(c.onClick||"");(e.withLoading?e.withLoading(`${n}-bn-${h}`,f):f()).catch(()=>{})};return E("button",{key:`${n}-bn-${h}`,onClick:u,style:{background:"none",border:"none",cursor:"pointer",flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:2,padding:"6px 0",color:a?s.primary:s.textMuted,fontSize:11,fontFamily:"inherit"},"aria-label":c.label||c.icon||"nav item"},c.icon?e.renderIcon(c.icon,20):null,c.label?E("span",{},c.label):null)}),l=e.getCommonProps(n,i,t);return E("div",{key:n,...l},...o)}function H1(e,t,n){const s=Array.isArray(t.panes)?t.panes:[],i=t.className?{display:"flex",flexDirection:"row",alignItems:"stretch",...e.parseClassName(t.className)}:{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%",flex:1,minHeight:0},r=s.map((l,c)=>{const a={width:l.width!==void 0?l.width:c===s.length-1?"1fr":"50%",minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},u=`${n}-split-${c}`;return E("div",{key:u,style:a},l.component?e.renderComponent(l.component,c,`${n}-split`):null)}),o=e.getCommonProps(n,i,t);return E("div",{key:n,...o},...r)}function q1(e,t,n){const s=e.cfg.colorMode!=="light",i=()=>{var l;return(l=e.setColorMode)==null?void 0:l.call(e,s?"light":"dark")},r=t.className?e.parseClassName(t.className):{background:"none",border:`1px solid ${e.cfg.colors.border}`,borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:6,padding:"6px 10px",color:e.cfg.colors.text,fontSize:14,fontFamily:"inherit"},o=e.getCommonProps(n,r,t);return E("button",{key:n,...o,onClick:i,"aria-label":s?"Switch to light mode":"Switch to dark mode"},E("span",{},s?"☀️":"🌙"),t.text?E("span",{},t.text):null)}function G1(e){var r;const{api:t,config:n}=e,s=t.interpolateText(n.channel||""),i=t.interpolateText(n.entityId||"");return m.useEffect(()=>{var w;const o=t.sdk;if(!t.isAuthenticated||!((w=o==null?void 0:o.client)!=null&&w.createWebSocket)||!s)return;let l=null,c=null,h=[],a=!1,u=null;const f=()=>{const C=t.interpolateText(n.resolution||"")||"",x=String(C).match(/(\d+)\s*x\s*(\d+)/);return x?{width:Number(x[1]),height:Number(x[2])}:{width:Number(t.interpolateText(n.width))||1280,height:Number(t.interpolateText(n.height))||720}},p=Number(t.interpolateText(n.fps))||10,g=async()=>{var x;if(a)return;a=!0,c&&c.state!=="inactive"&&await new Promise(k=>{c.onstop=()=>k(),c.stop()}),(x=l==null?void 0:l.close)==null||x.call(l);const C=new Blob(h,{type:"video/webm"});if(h=[],C.size!==0)try{const k=t.interpolateText(n.entityId||"")||"cast",S=t.interpolateText(n.fileName||"")||`${n.entityType||"video"}-${k}.webm`,T=new File([C],S,{type:"video/webm"}),P=await o.files.upload(T,{bucket:n.bucket||"backflow-storage",entityType:n.entityType||"video",entityId:k});t.setSceneData(I=>({...I,sessionId:k,[n.assetField||"asset_id"]:P==null?void 0:P.id,_recorded:P})),n.onRecorded&&t.handleButtonClick(String(n.onRecorded),{})}catch(k){Br("[recorder] upload failed:",k)}},d=()=>{if(c)return;const{width:C,height:x}=f(),k=document.createElement("canvas");k.width=C,k.height=x;const S=k.getContext("2d");if(S){u=T=>{const P=new Image;P.onload=()=>S.drawImage(P,0,0,C,x),P.src=T};try{const T=k.captureStream(p);c=new MediaRecorder(T,{mimeType:"video/webm",videoBitsPerSecond:5e6}),c.ondataavailable=P=>{P.data.size&&h.push(P.data)},c.start(500)}catch(T){Br("[recorder] start failed:",T),c=null}}};return l=o.client.createWebSocket(s),l.onmessage=C=>{let x=C==null?void 0:C.data;if(typeof x=="string")try{x=JSON.parse(x)}catch{return}(x==null?void 0:x.type)==="screencast_frame"&&x.frame?(d(),u==null||u(x.frame)):((x==null?void 0:x.status)==="completed"||(x==null?void 0:x.status)==="failed"||(x==null?void 0:x.type)==="workflow_completed"||(x==null?void 0:x.type)==="workflow_failed")&&g()},l.onclose=()=>g(),l.onerror=()=>g(),()=>{var C,x;a=!0,(C=c==null?void 0:c.stop)==null||C.call(c),(x=l==null?void 0:l.close)==null||x.call(l)}},[t.isAuthenticated,s,i,(r=e.config)==null?void 0:r.channel]),null}function Y1(e){const{api:t,config:n,componentKey:s}=e,i=t.interpolateText(n.channel||""),r=m.useRef(null),o=m.useRef(null),[l,c]=m.useState(!1);m.useEffect(()=>{const a=()=>c(document.fullscreenElement===r.current);return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[]);const h=async a=>{var f,p;a.preventDefault(),a.stopPropagation();const u=r.current;if(u){if(document.fullscreenElement){await((f=document.exitFullscreen)==null?void 0:f.call(document));return}await((p=u.requestFullscreen)==null?void 0:p.call(u))}};return m.useEffect(()=>{var d;const a=t.sdk;if(!t.isAuthenticated||!((d=a==null?void 0:a.client)!=null&&d.createWebSocket)||!i)return;let u=null,f=!1;const p=w=>{const C=o.current;if(!C)return;const x=new Image;x.onload=()=>{if(f)return;const k=C.getContext("2d");k&&(C.width=x.width,C.height=x.height,k.drawImage(x,0,0,C.width,C.height))},x.src=w},g=()=>{f||(u=a.client.createWebSocket(i),u.onmessage=w=>{let C=w==null?void 0:w.data;if(typeof C=="string")try{C=JSON.parse(C)}catch{return}(C==null?void 0:C.type)==="screencast_frame"&&C.frame&&p(C.frame)},u.onclose=()=>{f||setTimeout(g,3e3)},u.onerror=()=>{var w;(w=u==null?void 0:u.close)==null||w.call(u)})};return g(),()=>{var w;f=!0,(w=u==null?void 0:u.close)==null||w.call(u)}},[t.isAuthenticated,i,s]),m.createElement("div",{key:s,ref:r,className:"relative w-full h-full bg-black group",style:{width:"100%",height:"100%"}},m.createElement("canvas",{ref:o,className:t.parseClassName(n.className||"w-full h-full object-contain bg-black [aspect-ratio:16/9]"),style:{width:"100%",height:"100%",objectFit:"contain"}}),n.fullscreen===!1?null:m.createElement("button",{type:"button",onClick:h,title:l?"Exit fullscreen":"Open fullscreen","aria-label":l?"Exit fullscreen":"Open fullscreen",className:"absolute top-2 right-2 z-20 inline-flex h-8 w-8 items-center justify-center rounded-full bg-black/55 text-white transition-opacity hover:bg-black/75"},t.renderIcon(l?"minimize-2":"maximize-2",16)))}function Os(e,t,n,s,i){if(!Array.isArray(t)||t.length===0)return null;if(s==="row")return t.map((h,a)=>e.renderComponent(h,a,n));const r=[];let o=[];const l=h=>h&&(h.type==="button"||i&&(h.type==="link"||h.type==="a")),c=h=>{o.length!==0&&(o.length===1?r.push(e.renderComponent(o[0],h,n)):r.push(E("div",{key:`${n}-btns-${h}`,style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:"0.75rem"}},...o.map((a,u)=>e.renderComponent(a,h+u,n)))),o=[])};return t.forEach((h,a)=>{l(h)?o.push(h):(c(a),r.push(e.renderComponent(h,a,n)))}),c(t.length),r}function um(e){return e.className?/\bhidden\b/.test(e.className)&&/\b(sm|md|lg|xl):(?:block|flex|inline|inline-block|inline-flex)\b/.test(e.className):!1}function dm(e){return e.children?e.children.filter(t=>um(t)):[]}function X1(e){return e.children?e.children.filter(t=>!um(t)):[]}function fm(e){var t;return Array.isArray((t=e==null?void 0:e.mobileMenu)==null?void 0:t.items)?e.mobileMenu.items:[]}function Q1(e){if(!(e.layout==="row"||e.className&&/\bflex-row\b/.test(e.className)))return!1;const n=dm(e),s=fm(e);if(n.length===0&&s.length===0)return!1;const i=["text","link","button","accordion"];if(!(n.length===0||n.every(c=>i.includes(c.type))))return!1;const o=e.className||"";return/\b(sticky|fixed)\b/.test(o)||/\btop-0\b/.test(o)||/\bz-(10|20|30|40|50)\b/.test(o)||/\bjustify-between\b/.test(o)||e.justify==="space-between"}function Pu(e){const t=fm(e);return t.length>0?t:dm(e)}function _u(e){return X1(e)}function $u(e,t){return m.createElement("button",{key:"hamburger-icon",onClick:()=>t(!e),style:{background:"none",border:"none",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",color:"inherit",fontSize:"24px",lineHeight:1},"aria-label":e?"Close menu":"Open menu"},e?"✕":"☰")}function mm(e){return e=String(e??""),e.replace(/\bhidden\b/g,"").replace(/\b(sm|md|lg|xl|2xl):(block|flex|inline|inline-block|inline-flex)\b/g,"").replace(/\s+/g," ").trim()}function Nu(e){const t=(e==null?void 0:e.className)||"";return/\bdrawer\b/.test(t)&&!/\bdrawer-(item|item-[a-z]+)\b/.test(t)}function Ts(e){return/\bburger-first\b/.test((e==null?void 0:e.className)||"")}function Iu({navLinks:e,parentKey:t,renderComponentFn:n,open:s,onClose:i,colorMode:r,portalTarget:o,mobileMenu:l,parseMenuClassName:c}){const[h,a]=m.useState(s);if(m.useEffect(()=>{s&&a(!0)},[s]),!s&&!h)return null;const u=e.map(C=>({...C,className:C.className?mm(C.className):void 0})),f=r!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",p=l!=null&&l.className&&c?c(l.className,`${t}-side-drawer-class`):{},g=l!=null&&l.headerClassName&&c?c(l.headerClassName,`${t}-side-header-class`):{},d=()=>{a(!1),i()},w=m.createElement(m.Fragment,null,m.createElement("div",{key:`${t}-side-backdrop`,onClick:d,style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.45)",zIndex:90,opacity:s?1:0,transition:"opacity 0.25s ease",pointerEvents:s?"auto":"none"}}),m.createElement("div",{key:`${t}-side-drawer`,className:l==null?void 0:l.className,style:{position:"absolute",top:0,bottom:0,left:0,width:"min(300px, 85%)",backgroundColor:f,zIndex:100,overflowY:"auto",transform:s?"translateX(0)":"translateX(-100%)",transition:"transform 0.25s ease",boxShadow:"2px 0 12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",gap:"4px",padding:"16px 12px",...p}},m.createElement("div",{key:`${t}-side-header`,className:l==null?void 0:l.headerClassName,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px 12px",borderBottom:"1px solid rgba(128, 128, 128, 0.2)",marginBottom:"8px",fontSize:18,fontWeight:700,...g}},(l==null?void 0:l.title)||"Menu",m.createElement("button",{onClick:d,"aria-label":"Close menu",style:{background:"none",border:"none",cursor:"pointer",fontSize:22,color:"inherit",lineHeight:1}},"✕")),u.map((C,x)=>m.createElement(pm,{key:`${t}-drawer-item-${x}`,link:C,idx:x,parentKey:t,renderComponentFn:n,onClose:d,itemClassName:l==null?void 0:l.itemClassName,itemStyle:l!=null&&l.itemClassName&&c?c(l.itemClassName,`${t}-drawer-item-class-${x}`):void 0}))));return o?Wu.createPortal(w,o):w}function pm({link:e,idx:t,parentKey:n,renderComponentFn:s,onClose:i,itemClassName:r,itemStyle:o}){const[l,c]=m.useState(!1),h=e.type==="link"||e.type==="button";return m.createElement("div",{key:`${n}-drawer-item-${t}`,className:r,style:{display:"flex",flexDirection:"row",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",borderRadius:8,cursor:h?"pointer":"default",backgroundColor:l?"rgba(128, 128, 128, 0.12)":"transparent",transition:"background-color 0.15s ease",...o},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:()=>{h&&i()}},s(e,t+1,`${n}-drawer`))}function Du(e,t,n,s,i,r,o,l){if(!s)return null;const c=e.map(f=>({...f,className:f.className?mm(f.className):void 0})),h=i!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",a=i!=="light"?"rgba(75, 85, 99, 0.5)":"rgba(209, 213, 219, 0.5)",u=o!=null&&o.className&&l?l(o.className,`${t}-mobile-drawer-class`):{};return m.createElement("div",{key:`${t}-mobile-drawer`,className:o==null?void 0:o.className,style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:h,borderTop:`1px solid ${a}`,padding:"12px",display:"flex",flexDirection:"column",gap:"4px",zIndex:50,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",...u}},c.map((f,p)=>m.createElement(pm,{key:`${t}-drawer-item-${p}`,link:f,idx:p,parentKey:t,renderComponentFn:n,onClose:()=>r==null?void 0:r(!1),itemClassName:o==null?void 0:o.itemClassName,itemStyle:o!=null&&o.itemClassName&&l?l(o.itemClassName,`${t}-drawer-item-class-${p}`):void 0})))}function J1(e,t,n){var o;if(t.className){const l=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className);if(l.display==null&&(l.display="flex"),l.flexDirection==null){const h=t.className||"",a=h.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(a)l.flexDirection=a[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(h)){const u=/\bmin-h-(screen|\[[^\]]+\])/.test(h)&&/\bitems-center\b/.test(h),f=Array.isArray(t.children)&&t.children.length>0&&t.children.every(p=>p&&["h1","h2","h3","h4","p","text"].includes(p.type));l.flexDirection=u||f?"column":"row"}else l.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const h=Fi(t.className);if(h.px.size>0){const u=ht(h.px,e.containerWidth,"0px");l.paddingLeft=u,l.paddingRight=u}if(h.py.size>0){const u=ht(h.py,e.containerWidth,"0px");l.paddingTop=u,l.paddingBottom=u}if(h.p.size>0){const u=ht(h.p,e.containerWidth,"0px");l.padding=u}const a=Gs(t.className);a.size>0&&(l.display=ht(a,e.containerWidth,"flex"))}const c=e.getCommonProps(n,l,t);return m.createElement("div",{key:n,className:t.className,...c},Os(e,Array.isArray(t.children)?t.children:[],n,l.flexDirection))}const s=e.cfg.colorMode==="light",i={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"1rem",padding:"1.5rem",borderRadius:"1rem",backdropFilter:"blur(8px)",border:s?"1px solid rgba(0, 0, 0, 0.1)":"1px solid rgba(55, 65, 81, 0.5)"},r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...r},Os(e,t.children,n,i.flexDirection))}function K1(e,t,n){var l;const s=e.isMobileView&&Q1(t);if(t.className){const c=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(c.display==null&&(c.display="flex"),c.flexDirection==null){const u=t.className||"",f=u.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(f)c.flexDirection=f[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(u)){const p=/\bmin-h-(screen|\[[^\]]+\])/.test(u)&&/\bitems-center\b/.test(u),g=Array.isArray(t.children)&&t.children.length>0&&t.children.every(d=>d&&["h1","h2","h3","h4","p","text"].includes(d.type));c.flexDirection=p||g?"column":"row"}else c.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const u=Fi(t.className);if(u.px.size>0){const p=ht(u.px,e.containerWidth,"0px");c.paddingLeft=p,c.paddingRight=p}if(u.py.size>0){const p=ht(u.py,e.containerWidth,"0px");c.paddingTop=p,c.paddingBottom=p}if(u.p.size>0){const p=ht(u.p,e.containerWidth,"0px");c.padding=p}const f=Gs(t.className);f.size>0&&(c.display=ht(f,e.containerWidth,"flex"))}if(s&&t.children&&t.children.length>0){const u=_u(t),f=Pu(t);c.position="relative",c.display="flex",c.alignItems="center",c.justifyContent=Ts(t)?"flex-start":"space-between",Ts(t)&&(c.gap=10);const p=e.getCommonProps(n,c,t),g=$u(e.mobileMenuOpen,e.setMobileMenuOpen),d=(C,x)=>{var k;return((k=e.parseClassNameResponsive)==null?void 0:k.call(e,C,x))??e.parseClassName(C)},w=u.map((C,x)=>e.renderComponent(C,x,n));return m.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...p},...Ts(t)?[g,...w]:[...w,g],Nu(t)?m.createElement(Iu,{navLinks:f,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:d}):Du(f,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,d))}const h=e.getCommonProps(n,c,t),a=t.onClick?{onClick:u=>{u.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return m.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...h,...a},Os(e,Array.isArray(t.children)?t.children:[],n,c.flexDirection))}const i={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"16px"};if(t.align){const c={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};i.alignItems=c[t.align]}if(t.justify){const c={start:"flex-start",center:"center",end:"flex-end","space-between":"space-between"};i.justifyContent=c[t.justify]}if(t.padding!==void 0&&(i.padding=`${t.padding}px`),s&&t.children&&t.children.length>0){const c=_u(t),h=Pu(t);i.position="relative",i.display="flex",i.alignItems="center",i.justifyContent=Ts(t)?"flex-start":"space-between",Ts(t)&&(i.gap=10);const a=e.getCommonProps(n,i,t),u=$u(e.mobileMenuOpen,e.setMobileMenuOpen),f=(g,d)=>{var w;return((w=e.parseClassNameResponsive)==null?void 0:w.call(e,g,d))??e.parseClassName(g)},p=c.map((g,d)=>e.renderComponent(g,d,n));return m.createElement("div",{key:n,...a},...Ts(t)?[u,...p]:[...p,u],Nu(t)?m.createElement(Iu,{navLinks:h,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:f}):Du(h,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,f))}const r=e.getCommonProps(n,i,t),o=t.onClick?{onClick:c=>{c.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return m.createElement("div",{key:n,...r,...o},Os(e,t.children,n,i.flexDirection))}function Z1(e,t,n){var r,o;if(t.className){const l=((r=e.parseClassNameResponsive)==null?void 0:r.call(e,t.className,n))??e.parseClassName(t.className);let c;if(e.renderMode!=="css-driven"){const a=cv(t.className),u=a.size>0?hv(a,e.containerWidth):void 0;c={display:"grid",...l,...u!==void 0&&{gridTemplateColumns:`repeat(${u}, minmax(0, 1fr))`}}}else c={display:"grid",...l};const h=e.getCommonProps(n,c,t);return m.createElement("div",{key:n,className:t.className,...h},(Array.isArray(t.children)?t.children:[]).map((a,u)=>e.renderComponent(a,u,n)))}const s={display:"grid",width:"100%",gridTemplateColumns:`repeat(${t.cols||2}, minmax(0, 1fr))`,gap:t.gap!==void 0?`${t.gap}px`:"16px"},i=e.getCommonProps(n,s,t);return m.createElement("div",{key:n,...i},(o=t.children)==null?void 0:o.map((l,c)=>e.renderComponent(l,c,n)))}function tS(e,t,n){var l,c;if(t.className){const a={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:e.containerWidth>0&&e.containerWidth<_i.md?"300px":"500px",gap:"24px"};(t.bg||t.backgroundColor)&&(a.background=t.bg||t.backgroundColor),t.bgImage&&(a.backgroundImage=`url(${t.bgImage})`,a.backgroundSize="cover",a.backgroundPosition="center");const u={...a,...((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className)};if(Array.isArray(t.children)&&t.children.some(g=>g.type==="grid")||(u.textAlign="center"),e.renderMode!=="css-driven"){const g=Fi(t.className);if(g.px.size>0){const d=ht(g.px,e.containerWidth,"0px");u.paddingLeft=d,u.paddingRight=d}if(g.py.size>0){const d=ht(g.py,e.containerWidth,"0px");u.paddingTop=d,u.paddingBottom=d}if(g.p.size>0){const d=ht(g.p,e.containerWidth,"0px");u.padding=d}}const p=e.getCommonProps(n,u,t);return m.createElement("div",{key:n,className:t.className,...p},Os(e,Array.isArray(t.children)?t.children:[],n,u.flexDirection))}const s=e.containerWidth<_i.md,i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:s?"300px":"500px",padding:s?"1.5rem":"3rem",background:t.bg||t.backgroundColor,gap:"24px"};t.bgImage&&(i.backgroundImage=`url(${t.bgImage})`,i.backgroundSize="cover",i.backgroundPosition="center"),Array.isArray(t.children)&&t.children.some(h=>h.type==="grid")||(i.textAlign="center");const o=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...o},(c=t.children)==null?void 0:c.map((h,a)=>e.renderComponent(h,a,n)))}function eS(e,t,n){var o;const s={display:"flex",flexDirection:"row",alignItems:"center",width:"100%",flexShrink:0,position:"sticky",top:0,zIndex:50,gap:"1.25rem",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colors.surface,borderBottom:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(s,((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const l=Fi(t.className);l.px.size>0&&(s.paddingLeft=ht(l.px,e.containerWidth,"0px"),s.paddingRight=ht(l.px,e.containerWidth,"0px")),l.py.size>0&&(s.paddingTop=ht(l.py,e.containerWidth,"0px"),s.paddingBottom=ht(l.py,e.containerWidth,"0px"));const c=Gs(t.className);c.size>0&&(s.display=ht(c,e.containerWidth,"flex"))}const i=e.getCommonProps(n,s,t),r=t.className?{key:n,className:t.className,...i}:{key:n,...i};return m.createElement("header",r,(Array.isArray(t.children)?t.children:[]).filter(l=>Array.isArray(l.visibleOn)?l.visibleOn.includes(e.currentSceneId):Array.isArray(l.hiddenOn)?!l.hiddenOn.includes(e.currentSceneId):!0).map((l,c)=>e.renderComponent(l,c,n)))}function nS(e,t,n){var c;const s={display:"flex",flexDirection:t.layout==="row"?"row":"column",width:"100%",flexShrink:0,marginTop:"auto",gap:"1rem",padding:"2.5rem 1.5rem",backgroundColor:e.cfg.colors.surfaceHover,borderTop:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(s,((c=e.parseClassNameResponsive)==null?void 0:c.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const h=Fi(t.className);h.px.size>0&&(s.paddingLeft=ht(h.px,e.containerWidth,"0px"),s.paddingRight=ht(h.px,e.containerWidth,"0px")),h.py.size>0&&(s.paddingTop=ht(h.py,e.containerWidth,"0px"),s.paddingBottom=ht(h.py,e.containerWidth,"0px"))}const i=e.getCommonProps(n,s,t),r=t.className?{key:n,className:t.className,...i}:{key:n,...i};let o=Array.isArray(t.children)?t.children:[];const l=o[0];return l&&l.type==="text"&&/^(\u00a9|\(c\)|copyright)/i.test(String(l.text).trim())&&(o=[...o.slice(1),l]),m.createElement("footer",r,Os(e,o,n,s.flexDirection,!0))}const Lu=new Map;function sS(e){let t=Lu.get(e);return t||(t=Nr.create(e),Lu.set(e,t)),t}function lt(e,t){if(!(e!=null&&e.motion)||!m.isValidElement(t))return t;const n=t,s=n.props,i=sS(n.type);return m.createElement(i,{key:n.key,...s,initial:e.initial,animate:e.animate,exit:e.exit,transition:e.transition,variants:e.variants,whileHover:e.whileHover,whileTap:e.whileTap,whileFocus:e.whileFocus,whileInView:e.whileInView,layout:e.animateLayout},s==null?void 0:s.children)}function Cr(e,t,n,s=""){var o;const i=t,r=`${s}-${n}`;if(Array.isArray(i.hiddenOn)&&i.hiddenOn.includes(e.currentSceneId)||Array.isArray(i.visibleOn)&&!i.visibleOn.includes(e.currentSceneId)||i.condition&&e.evaluateCondition&&!e.evaluateCondition(i.condition))return null;if(!Array.isArray(i.children)&&Array.isArray(i.components)&&(i.children=i.components),i.type==="custom"){const l=i.tagName||"div",c=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,i.className||"",r))??(i.className?e.parseClassName(i.className):{});i.rawStyle&&Object.assign(c,i.rawStyle);const h=e.getCommonProps(r,c,i),a=Array.isArray(i.children)?i.children.map((f,p)=>e.renderComponent(f,p,r)):[],u=i.motion?{motion:i.motion,initial:i.initial,animate:i.animate,exit:i.exit,transition:i.transition,variants:i.variants,whileHover:i.whileHover,whileTap:i.whileTap,whileFocus:i.whileFocus,whileInView:i.whileInView,animateLayout:i.animateLayout}:{};return E(l,{key:r,className:i.className,...h,...u},...a)}if(/^h[1-6]$/.test(i.type)||i.type==="p"||i.type==="span"||i.type==="label"||i.type==="blockquote"||i.type==="strong"||i.type==="em"||i.type==="li"||i.type==="figcaption"||i.type==="th"||i.type==="td"||i.type==="heading"||i.type==="paragraph"||i.type==="address"||i.type==="time"||i.type==="legend"||i.type==="caption"?i.type="text":i.type==="div"||i.type==="article"||i.type==="aside"||i.type==="main"||i.type==="figure"?i.type=i.children?"section":"text":i.type==="a"?i.type="link":i.type==="img"?i.type="image":i.type==="ul"||i.type==="ol"?i.type="list":i.type==="table"||i.type==="thead"||i.type==="tbody"||i.type==="tfoot"||i.type==="tr"?i.type="table":i.type==="br"?i.type="spacer":i.type==="hr"?i.type="divider":i.type==="details"||i.type==="summary"?i.type=i.children?"section":"text":i.type==="nav"?i.type="section":(i.type==="form"&&!i.fields||i.type==="listItem")&&(i.type=i.children?"section":"text"),i.type==="select"&&Array.isArray(i.options)&&typeof i.options[0]=="string"&&(i.options=i.options.map(l=>({label:l,value:l}))),i.type==="dropdown-button"&&!i.items&&i.options&&(i.items=Array.isArray(i.options)&&typeof i.options[0]=="string"?i.options.map(l=>({label:l,value:l})):i.options),(i.type==="input"||i.type==="textarea")&&!i.placeholder&&i.label&&(i.placeholder=i.label),e.imageReplacements&&e.imageReplacements.size>0){const l=e.imageReplacements.get(r);if(l&&l.url){const c={width:"100%",height:"auto",maxHeight:"300px",objectFit:"cover",borderRadius:"0.75rem"},h=e.getCommonProps(r,c,i),a=i.motion?{motion:i.motion,initial:i.initial,animate:i.animate,whileHover:i.whileHover,whileTap:i.whileTap,transition:i.transition,animateLayout:i.animateLayout}:{};return E("img",{key:`${r}-${l.url}`,src:l.url,alt:l.name||"Replacement image",...h,...a})}}switch(i.type){case"text":return lt(i,Jw(e,i,r));case"html":return lt(i,Zw(e,i,r));case"link":return lt(i,t1(e,i,r));case"button":return lt(i,e1(e,i,r));case"image":return lt(i,n1(e,i,r));case"input":return lt(i,s1(e,i,r));case"hidden":return lt(i,i1(e,i,r));case"select":return lt(i,r1(e,i,r));case"checkbox":return lt(i,o1(e,i,r));case"card":return lt(i,J1(e,i,r));case"section":case"container":case"cta_section":return lt(i,K1(e,i,r));case"header":return lt(i,eS(e,i,r));case"grid":case"features_grid":return lt(i,Z1(e,i,r));case"hero":return lt(i,tS(e,i,r));case"footer":return lt(i,nS(e,i,r));case"spacer":return lt(i,g1(e,i,r));case"divider":return lt(i,y1(e,i,r));case"list":return lt(i,fv(e,i,r));case"table":return lt(i,pv(e,i,r));case"badge":return lt(i,a1(e,i,r));case"tag":return lt(i,l1(e,i,r));case"avatar":return lt(i,c1(e,i,r));case"progress":return lt(i,h1(e,i,r));case"recorder":return m.createElement(G1,{api:e,config:i,key:r});case"live-cast":return m.createElement(Y1,{api:e,config:i,componentKey:r,key:r});case"tabs":return lt(i,uv(e,i,r));case"accordion":return lt(i,dv(e,i,r));case"bottom_nav":return lt(i,U1(e,i,r));case"split":return lt(i,H1(e,i,r));case"theme_toggle":return lt(i,q1(e,i,r));case"slider":case"carousel":return lt(i,f1(e,i,r));case"marquee":return lt(i,m1(e,i,r));case"camera":case"capture":return lt(i,p1(e,i,r));case"phaser_game":return lt(i,e.renderPhaserGame?e.renderPhaserGame(i,r):null);case"search":return lt(i,u1(e,i,r));case"breadcrumb":return lt(i,d1(e,i,r));case"form":return lt(i,L1(e,i,r));case"textarea":return lt(i,v1(e,i,r));case"icon":return lt(i,x1(e,i,r));case"markdown":return lt(i,O1(e,i,r));case"dropdown-button":return lt(i,$1(e,i,r));case"widget":return lt(i,N1(e,i,r));case"advanced-select":return lt(i,I1(e,i,r));case"metric_display":return lt(i,w1(e,i,r));case"bar_chart":return lt(i,S1(e,i,r));case"line_chart":return lt(i,Go(e,i,r,!1));case"area_chart":return lt(i,Go(e,i,r,!0));case"candlestick":return lt(i,Go(e,i,r,!1,!0));case"fx_ticker":return lt(i,C1(e,i,r));case"trading_view":return lt(i,M1(e,i,r));case"loader":return lt(i,b1(e,i,r));case"flow_diagram":return lt(i,E1(e,i,r));case"flow":return lt(i,A1(e,i,r));default:return lt(i,R1(e,i,r))}}function gm(e){const t=new Map,n=new Map;for(const s of e)if(s.type==="render_scene"&&s.route){const i=s.route.startsWith("/")?s.route:`/${s.route}`;t.set(s.id,i),n.set(i,s.id)}for(const s of e)if(s.type==="render_scene"&&!t.has(s.id)){const i=`/${s.id}`;t.set(s.id,i),n.set(i,s.id)}return{sceneToRoute:t,routeToScene:n}}function Ta(e){if(typeof window>"u")return null;const t=window.location.hash;if(!t||t==="#")return null;const n=t.slice(1);return e.get(n)||null}function kr(e,t,n=!1){if(typeof window>"u")return;const s=t.get(e);if(!s)return;const i=`#${s}`;window.location.hash!==i&&(n?window.history.replaceState({sceneId:e},"",i):window.history.pushState({sceneId:e},"",i))}const iS=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1};async function Mr(e,t,n={},s){var i;try{const r=t.indexOf(".");if(r===-1)throw new Error(`Invalid SDK call syntax: ${t}`);const o=t.slice(0,r),l=t.slice(r+1),c=l.indexOf("(");if(c===-1)throw new Error(`Invalid SDK call syntax (missing parentheses): ${t}`);const h=l.slice(0,c),a=l.slice(c+1,-1),u=rS(a,n);let f=e[o];if(!f)throw new Error(`Unknown SDK resource: ${String(o)}`);const p=h.split(".");for(let w=0;w<p.length-1;w++){const C=p[w];if(C&&(f=f[C],!f))throw new Error(`Unknown path ${p.slice(0,w+1).join(".")} on resource ${String(o)}`)}const g=p[p.length-1],d=f[g];if(typeof d!="function")throw new Error(`Unknown method ${g} on ${String(o)}.${p.slice(0,-1).join(".")}`);return await d.apply(f,u)}catch(r){throw iS()&&console.error("[SDK Executor] Error:",r),(i=s==null?void 0:s.onError)==null||i.call(s,r),r}}function rS(e,t){if(!e.trim())return[];const s=e.replace(/\{\{([\w.]+)\}\}/g,(i,r)=>{if(r==="now")return JSON.stringify(new Date().toISOString());const o=aS(t,r);return o===void 0?"null":typeof o=="string"?`"${o}"`:JSON.stringify(o)}).replace(/([{,]\s*)([A-Za-z_$][\w$]*)\s*:/g,'$1"$2":').replace(/'((?:[^'\\]|\\.)*)'/g,(i,r)=>`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`);try{return JSON.parse(`[${s}]`)}catch{return oS(s).map(i=>{const r=i.trim();if(r.startsWith("'")&&r.endsWith("'")||r.startsWith('"')&&r.endsWith('"'))return r.slice(1,-1);if(!isNaN(Number(r)))return Number(r);if(r==="true")return!0;if(r==="false")return!1;if(r==="null")return null;try{return JSON.parse(r)}catch{return r}})}}function oS(e){const t=[];let n="",s=0,i=null;for(let r=0;r<e.length;r++){const o=e[r],l=e[r-1];if((o==='"'||o==="'")&&l!=="\\"&&(i===o?i=null:i||(i=o)),!i&&((o==="{"||o==="["||o==="(")&&s++,(o==="}"||o==="]"||o===")")&&s--,o===","&&s===0)){t.push(n),n="";continue}n+=o}return n.trim()&&t.push(n),t}function aS(e,t){const n=t.split(".");let s=e;for(const i of n){if(s==null)return;s=s[i]}return s}function Ci(e){return e.startsWith("sdk:")}function pi(e){return Ci(e)?e.slice(4):e}function lS(e,t,...n){const s=n.map(i=>typeof i=="string"?`'${i}'`:JSON.stringify(i)).join(", ");return`sdk:${e}.${t}(${s})`}function cS(e,t){const n=new Map,s=(i,r)=>{r.size>0&&n.set(i,r)};return s("--bf-fd",e.flexDirection),s("--bf-gap",e.gap),s("--bf-w",e.width),s("--bf-items",e.alignItems),s("--bf-justify",e.justifyContent),s("--bf-display",e.display),s("--bf-cols",e.gridCols),s("--bf-text",e.textSize),s("--bf-radius",e.borderRadius),e.padding.p.size>0&&s("--bf-p",e.padding.p),e.padding.px.size>0&&s("--bf-px",e.padding.px),e.padding.py.size>0&&s("--bf-py",e.padding.py),e.margin.all.size>0&&s("--bf-m",e.margin.all),e.margin.t.size>0&&s("--bf-mt",e.margin.t),e.margin.r.size>0&&s("--bf-mr",e.margin.r),e.margin.b.size>0&&s("--bf-mb",e.margin.b),e.margin.l.size>0&&s("--bf-ml",e.margin.l),e.margin.x.size>0&&s("--bf-mx",e.margin.x),e.margin.y.size>0&&s("--bf-my",e.margin.y),n}function hS(e,t){const n=String(t).replace(/[^a-zA-Z0-9_-]/g,"_");return`${e}-${n}`}function ym(e,t,n){const s=cS(n);if(s.size===0)return"";const i=`[data-bf-r="${e}-${t}"]`,r=[];for(const o of Rf){if(o==="base")continue;const l=Af[o],c=[];for(const[h,a]of s)a.has(o)&&(hS(h,t),c.push(` ${h.replace("--bf-","--bf-")}: ${a.get(o)};`));c.length>0&&r.push(`@media (min-width: ${l}px) {
|
|
18
18
|
${i} {
|
|
19
19
|
${c.join(`
|
|
20
20
|
`)}
|
|
21
21
|
}
|
|
22
22
|
}`)}return r.join(`
|
|
23
|
-
`)}const lS={slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},Aa={transparent:"transparent",current:"currentColor",inherit:"inherit",black:"#000000",white:"#ffffff",primary:"#3b82f6",secondary:"#64748b",accent:"#ec4899",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"};for(const[e,t]of Object.entries(lS))for(const[n,s]of Object.entries(t))Aa[`${e}-${n}`]=s;const vt={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},cS={xs:{fontSize:"0.75rem",lineHeight:"1rem"},sm:{fontSize:"0.875rem",lineHeight:"1.25rem"},base:{fontSize:"1rem",lineHeight:"1.5rem"},lg:{fontSize:"1.125rem",lineHeight:"1.75rem"},xl:{fontSize:"1.25rem",lineHeight:"1.75rem"},"2xl":{fontSize:"1.5rem",lineHeight:"2rem"},"3xl":{fontSize:"1.875rem",lineHeight:"2.25rem"},"4xl":{fontSize:"2.25rem",lineHeight:"2.5rem"},"5xl":{fontSize:"3rem",lineHeight:"1"},"6xl":{fontSize:"3.75rem",lineHeight:"1"},"7xl":{fontSize:"4.5rem",lineHeight:"1"},"8xl":{fontSize:"6rem",lineHeight:"1"},"9xl":{fontSize:"8rem",lineHeight:"1"}};function Al(e,t,n=!0){if(!e)return{};e=String(e);const{colorMode:s,...i}=t||{},r=s==="light",o=e.match(/(?:^|\s)dark:([^\s]+)/g)||[],l=e.replace(/(?:^|\s)dark:[^\s]+/g," ").replace(/\s+/g," ").trim();!r&&o.length?e=l?`${l} ${o.map(d=>d.trim().replace(/^dark:/,"")).join(" ")}`:o.map(d=>d.trim().replace(/^dark:/,"")).join(" "):e=l;const c=i?{...Aa,...Object.fromEntries(Object.entries(i).filter(([,d])=>d))}:Aa;r&&n&&(c.white="#000000",c.black="#ffffff",c["gray-300"]="#4b5563",c["gray-400"]="#374151",c["gray-500"]="#374151",c["gray-600"]="#1f2937",c["gray-700"]="#111827",c["gray-800"]="#0f172a",c["slate-300"]="#475569",c["slate-400"]="#334155",c["slate-500"]="#334155",c["slate-600"]="#1e293b");const h=e.split(/\s+/).filter(Boolean),a={};let u="",f="",p="",g="";for(let d of h){if(d.startsWith("hover:")||d.startsWith("focus:")||d.startsWith("active:")||d.startsWith("group-hover:")||d==="transition"||d==="transition-all"||d==="transition-colors"||d==="transition-opacity"||d==="transition-transform"||d.startsWith("duration-")||d.startsWith("ease-")||d==="cursor-pointer"||d==="grayscale"||((d.startsWith("sm:")||d.startsWith("md:")||d.startsWith("lg:")||d.startsWith("xl:")||d.startsWith("2xl:"))&&(d=d.replace(/^(sm:|md:|lg:|xl:|2xl:)/,"")),d.startsWith("placeholder-"))||d.startsWith("disabled:"))continue;const w=d.match(/^bg-\[([^\]]+)\]$/);if(w){const tt=w[1];tt.startsWith("url(")?a.backgroundImage=tt:a.backgroundColor=tt;continue}const C=d.match(/^text-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\)|hsl[a]?\([^)]+\))\]$/);if(C){a.color=C[1];continue}const x=d.match(/^text-\[(\d+(?:\.\d+)?(?:px|rem|em|%))\]$/);if(x){a.fontSize=x[1];continue}const k=d.match(/^w-\[([^\]]+)\]$/);if(k){a.width=k[1];continue}const S=d.match(/^h-\[([^\]]+)\]$/);if(S){a.height=S[1];continue}const T=d.match(/^min-w-\[([^\]]+)\]$/);if(T){a.minWidth=T[1];continue}const P=d.match(/^max-w-\[([^\]]+)\]$/);if(P){a.maxWidth=P[1];continue}const I=d.match(/^min-h-\[([^\]]+)\]$/);if(I){a.minHeight=I[1];continue}const L=d.match(/^max-h-\[([^\]]+)\]$/);if(L){a.maxHeight=L[1];continue}const O=d.match(/^p-\[([^\]]+)\]$/);if(O){a.padding=O[1];continue}const H=d.match(/^px-\[([^\]]+)\]$/);if(H){a.paddingLeft=H[1],a.paddingRight=H[1];continue}const U=d.match(/^py-\[([^\]]+)\]$/);if(U){a.paddingTop=U[1],a.paddingBottom=U[1];continue}const q=d.match(/^pt-\[([^\]]+)\]$/);if(q){a.paddingTop=q[1];continue}const X=d.match(/^pr-\[([^\]]+)\]$/);if(X){a.paddingRight=X[1];continue}const V=d.match(/^pb-\[([^\]]+)\]$/);if(V){a.paddingBottom=V[1];continue}const D=d.match(/^pl-\[([^\]]+)\]$/);if(D){a.paddingLeft=D[1];continue}const j=d.match(/^m-\[([^\]]+)\]$/);if(j){a.margin=j[1];continue}const J=d.match(/^mx-\[([^\]]+)\]$/);if(J){a.marginLeft=J[1],a.marginRight=J[1];continue}const nt=d.match(/^my-\[([^\]]+)\]$/);if(nt){a.marginTop=nt[1],a.marginBottom=nt[1];continue}const it=d.match(/^mt-\[([^\]]+)\]$/);if(it){a.marginTop=it[1];continue}const Q=d.match(/^mr-\[([^\]]+)\]$/);if(Q){a.marginRight=Q[1];continue}const ut=d.match(/^mb-\[([^\]]+)\]$/);if(ut){a.marginBottom=ut[1];continue}const Ct=d.match(/^ml-\[([^\]]+)\]$/);if(Ct){a.marginLeft=Ct[1];continue}const ft=d.match(/^gap-\[([^\]]+)\]$/);if(ft){a.gap=ft[1];continue}const Dt=d.match(/^gap-x-\[([^\]]+)\]$/);if(Dt){a.columnGap=Dt[1];continue}const qt=d.match(/^gap-y-\[([^\]]+)\]$/);if(qt){a.rowGap=qt[1];continue}const ne=d.match(/^rounded-\[([^\]]+)\]$/);if(ne){a.borderRadius=ne[1];continue}const te=d.match(/^border-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\))\]$/);if(te){a.borderColor=te[1];continue}const mt=d.match(/^border-\[(\d+(?:\.\d+)?(?:px)?)\]$/);if(mt){a.borderWidth=mt[1];continue}const he=d.match(/^top-\[([^\]]+)\]$/);if(he){a.top=he[1];continue}const Pe=d.match(/^right-\[([^\]]+)\]$/);if(Pe){a.right=Pe[1];continue}const ae=d.match(/^bottom-\[([^\]]+)\]$/);if(ae){a.bottom=ae[1];continue}const Nn=d.match(/^left-\[([^\]]+)\]$/);if(Nn){a.left=Nn[1];continue}const Ys=d.match(/^inset-\[([^\]]+)\]$/);if(Ys){a.inset=Ys[1];continue}const Oe=d.match(/^z-\[([^\]]+)\]$/);if(Oe){a.zIndex=parseInt(Oe[1])||Oe[1];continue}const xe=d.match(/^opacity-\[([^\]]+)\]$/);if(xe){a.opacity=parseFloat(xe[1]);continue}const bt=d.match(/^leading-\[([^\]]+)\]$/);if(bt){a.lineHeight=bt[1];continue}if(d==="flex"){a.display="flex";continue}if(d==="grid"){a.display="grid";continue}if(d==="block"){a.display="block";continue}if(d==="inline"){a.display="inline";continue}if(d==="inline-flex"){a.display="inline-flex";continue}if(d==="inline-block"){a.display="inline-block";continue}if(d==="hidden"){a.display="none";continue}if(d==="flex-col"){a.flexDirection="column";continue}if(d==="flex-row"){a.flexDirection="row";continue}if(d==="flex-wrap"){a.flexWrap="wrap";continue}if(d==="flex-nowrap"){a.flexWrap="nowrap";continue}if(d==="flex-col-reverse"){a.flexDirection="column-reverse";continue}if(d==="flex-row-reverse"){a.flexDirection="row-reverse";continue}if(d==="flex-1"){a.flex="1 1 0%";continue}if(d==="flex-auto"){a.flex="1 1 auto";continue}if(d==="flex-initial"){a.flex="0 1 auto";continue}if(d==="flex-none"){a.flex="none";continue}if(d==="grow"){a.flexGrow=1;continue}if(d==="grow-0"){a.flexGrow=0;continue}if(d==="shrink"){a.flexShrink=1;continue}if(d==="shrink-0"){a.flexShrink=0;continue}if(d==="items-start"){a.alignItems="flex-start";continue}if(d==="items-center"){a.alignItems="center";continue}if(d==="items-end"){a.alignItems="flex-end";continue}if(d==="items-stretch"){a.alignItems="stretch";continue}if(d==="items-baseline"){a.alignItems="baseline";continue}if(d==="justify-start"){a.justifyContent="flex-start";continue}if(d==="justify-center"){a.justifyContent="center";continue}if(d==="justify-end"){a.justifyContent="flex-end";continue}if(d==="justify-between"){a.justifyContent="space-between";continue}if(d==="justify-around"){a.justifyContent="space-around";continue}if(d==="justify-evenly"){a.justifyContent="space-evenly";continue}if(d==="justify-items-start"){a.justifyItems="start";continue}if(d==="justify-items-center"){a.justifyItems="center";continue}if(d==="justify-items-end"){a.justifyItems="end";continue}if(d==="justify-items-stretch"){a.justifyItems="stretch";continue}if(d==="self-auto"){a.alignSelf="auto";continue}if(d==="self-start"){a.alignSelf="flex-start";continue}if(d==="self-center"){a.alignSelf="center";continue}if(d==="self-end"){a.alignSelf="flex-end";continue}if(d==="self-stretch"){a.alignSelf="stretch";continue}if(d==="self-baseline"){a.alignSelf="baseline";continue}if(d==="justify-self-auto"){a.justifySelf="auto";continue}if(d==="justify-self-start"){a.justifySelf="start";continue}if(d==="justify-self-center"){a.justifySelf="center";continue}if(d==="justify-self-end"){a.justifySelf="end";continue}if(d==="justify-self-stretch"){a.justifySelf="stretch";continue}if(d==="place-content-center"){a.placeContent="center";continue}if(d==="place-content-start"){a.placeContent="start";continue}if(d==="place-content-end"){a.placeContent="end";continue}if(d==="place-content-between"){a.placeContent="space-between";continue}if(d==="place-content-around"){a.placeContent="space-around";continue}if(d==="place-content-evenly"){a.placeContent="space-evenly";continue}if(d==="place-content-stretch"){a.placeContent="stretch";continue}if(d==="place-items-start"){a.placeItems="start";continue}if(d==="place-items-center"){a.placeItems="center";continue}if(d==="place-items-end"){a.placeItems="end";continue}if(d==="place-items-stretch"){a.placeItems="stretch";continue}if(d==="text-left"){a.textAlign="left";continue}if(d==="text-center"){a.textAlign="center";continue}if(d==="text-right"){a.textAlign="right";continue}if(d==="text-justify"){a.textAlign="justify";continue}if(d==="text-start"){a.textAlign="start";continue}if(d==="text-end"){a.textAlign="end";continue}if(d==="whitespace-normal"){a.whiteSpace="normal";continue}if(d==="whitespace-nowrap"){a.whiteSpace="nowrap";continue}if(d==="whitespace-pre"){a.whiteSpace="pre";continue}if(d==="whitespace-pre-line"){a.whiteSpace="pre-line";continue}if(d==="whitespace-pre-wrap"){a.whiteSpace="pre-wrap";continue}if(d==="whitespace-break-spaces"){a.whiteSpace="break-spaces";continue}if(d==="break-normal"){a.wordBreak="normal",a.overflowWrap="normal";continue}if(d==="break-words"){a.overflowWrap="break-word";continue}if(d==="break-all"){a.wordBreak="break-all";continue}if(d==="break-keep"){a.wordBreak="keep-all";continue}if(d==="truncate"){a.overflow="hidden",a.textOverflow="ellipsis",a.whiteSpace="nowrap";continue}if(d==="text-ellipsis"){a.textOverflow="ellipsis";continue}if(d==="text-clip"){a.textOverflow="clip";continue}if(d==="underline"){a.textDecoration="underline";continue}if(d==="overline"){a.textDecoration="overline";continue}if(d==="line-through"){a.textDecoration="line-through";continue}if(d==="no-underline"){a.textDecoration="none";continue}if(d==="uppercase"){a.textTransform="uppercase";continue}if(d==="lowercase"){a.textTransform="lowercase";continue}if(d==="capitalize"){a.textTransform="capitalize";continue}if(d==="normal-case"){a.textTransform="none";continue}if(d==="italic"){a.fontStyle="italic";continue}if(d==="not-italic"){a.fontStyle="normal";continue}if(d==="font-thin"){a.fontWeight=100;continue}if(d==="font-extralight"){a.fontWeight=200;continue}if(d==="font-light"){a.fontWeight=300;continue}if(d==="font-normal"){a.fontWeight=400;continue}if(d==="font-medium"){a.fontWeight=500;continue}if(d==="font-semibold"){a.fontWeight=600;continue}if(d==="font-bold"){a.fontWeight=700;continue}if(d==="font-extrabold"){a.fontWeight=800;continue}if(d==="font-black"){a.fontWeight=900;continue}if(d==="w-full"){a.width="100%";continue}if(d==="w-screen"){a.width="100vw";continue}if(d==="w-auto"){a.width="auto";continue}if(d==="w-fit"){a.width="fit-content";continue}if(d==="w-min"){a.width="min-content";continue}if(d==="w-max"){a.width="max-content";continue}const Rt=d.match(/^w-(\d+(?:\.\d+)?)$/);if(Rt){a.width=vt[Rt[1]]||`${parseFloat(Rt[1])*.25}rem`;continue}const Lt=d.match(/^w-(\d+)\/(\d+)$/);if(Lt){const tt=parseInt(Lt[1])/parseInt(Lt[2])*100;a.width=`${tt}%`;continue}if(d==="h-full"){a.height="100%";continue}if(d==="h-screen"){a.height="100vh";continue}if(d==="h-auto"){a.height="auto";continue}if(d==="h-fit"){a.height="fit-content";continue}if(d==="h-min"){a.height="min-content";continue}if(d==="h-max"){a.height="max-content";continue}const kt=d.match(/^h-(\d+(?:\.\d+)?)$/);if(kt){a.height=vt[kt[1]]||`${parseFloat(kt[1])*.25}rem`;continue}const yt=d.match(/^h-(\d+)\/(\d+)$/);if(yt){const tt=parseInt(yt[1])/parseInt(yt[2])*100;a.height=`${tt}%`;continue}if(d==="min-h-screen"){a.minHeight="100vh";continue}if(d==="min-h-full"){a.minHeight="100%";continue}if(d==="min-h-0"){a.minHeight="0";continue}if(d==="min-h-fit"){a.minHeight="fit-content";continue}const wt=d.match(/^min-h-(\d+(?:\.\d+)?)$/);if(wt){a.minHeight=vt[wt[1]]||`${parseFloat(wt[1])*.25}rem`;continue}if(d==="min-w-0"){a.minWidth="0";continue}if(d==="min-w-full"){a.minWidth="100%";continue}if(d==="min-w-fit"){a.minWidth="fit-content";continue}const gt=d.match(/^min-w-(\d+(?:\.\d+)?)$/);if(gt){a.minWidth=vt[gt[1]]||`${parseFloat(gt[1])*.25}rem`;continue}if(d==="max-w-none"){a.maxWidth="none";continue}if(d==="max-w-xs"){a.maxWidth="20rem";continue}if(d==="max-w-sm"){a.maxWidth="24rem";continue}if(d==="max-w-md"){a.maxWidth="28rem";continue}if(d==="max-w-lg"){a.maxWidth="32rem";continue}if(d==="max-w-xl"){a.maxWidth="36rem";continue}if(d==="max-w-2xl"){a.maxWidth="42rem";continue}if(d==="max-w-3xl"){a.maxWidth="48rem";continue}if(d==="max-w-4xl"){a.maxWidth="56rem";continue}if(d==="max-w-5xl"){a.maxWidth="64rem";continue}if(d==="max-w-6xl"){a.maxWidth="72rem";continue}if(d==="max-w-7xl"){a.maxWidth="80rem";continue}if(d==="max-w-full"){a.maxWidth="100%";continue}if(d==="max-w-prose"){a.maxWidth="65ch";continue}if(d==="max-w-screen-sm"){a.maxWidth="640px";continue}if(d==="max-w-screen-md"){a.maxWidth="768px";continue}if(d==="max-w-screen-lg"){a.maxWidth="1024px";continue}if(d==="max-w-screen-xl"){a.maxWidth="1280px";continue}if(d==="max-w-screen-2xl"){a.maxWidth="1536px";continue}if(d==="max-h-none"){a.maxHeight="none";continue}if(d==="max-h-full"){a.maxHeight="100%";continue}if(d==="max-h-screen"){a.maxHeight="100vh";continue}if(d==="max-h-fit"){a.maxHeight="fit-content";continue}const Xt=d.match(/^max-h-(\d+(?:\.\d+)?)$/);if(Xt){a.maxHeight=vt[Xt[1]]||`${parseFloat(Xt[1])*.25}rem`;continue}if(d==="relative"){a.position="relative";continue}if(d==="absolute"){a.position="absolute";continue}if(d==="fixed"){a.position="fixed";continue}if(d==="sticky"){a.position="sticky";continue}if(d==="inset-0"){a.top="0",a.right="0",a.bottom="0",a.left="0";continue}if(d==="inset-auto"){a.top="auto",a.right="auto",a.bottom="auto",a.left="auto";continue}if(d==="inset-x-0"){a.left="0",a.right="0";continue}if(d==="inset-y-0"){a.top="0",a.bottom="0";continue}const Ue=d.match(/^inset-(\d+(?:\.\d+)?)$/);if(Ue){const tt=vt[Ue[1]]||`${parseFloat(Ue[1])*.25}rem`;a.top=tt,a.right=tt,a.bottom=tt,a.left=tt;continue}const ge=d.match(/^inset-x-(\d+(?:\.\d+)?)$/);if(ge){const tt=vt[ge[1]]||`${parseFloat(ge[1])*.25}rem`;a.left=tt,a.right=tt;continue}const ee=d.match(/^inset-y-(\d+(?:\.\d+)?)$/);if(ee){const tt=vt[ee[1]]||`${parseFloat(ee[1])*.25}rem`;a.top=tt,a.bottom=tt;continue}if(d==="top-0"){a.top="0";continue}if(d==="top-auto"){a.top="auto";continue}if(d==="top-full"){a.top="100%";continue}const rs=d.match(/^top-(\d+(?:\.\d+)?)$/);if(rs){a.top=vt[rs[1]]||`${parseFloat(rs[1])*.25}rem`;continue}const ue=d.match(/^-top-(\d+(?:\.\d+)?)$/);if(ue){const tt=vt[ue[1]]||`${parseFloat(ue[1])*.25}rem`;a.top=`-${tt}`;continue}if(d==="right-0"){a.right="0";continue}if(d==="right-auto"){a.right="auto";continue}if(d==="right-full"){a.right="100%";continue}const ot=d.match(/^right-(\d+(?:\.\d+)?)$/);if(ot){a.right=vt[ot[1]]||`${parseFloat(ot[1])*.25}rem`;continue}const Me=d.match(/^-right-(\d+(?:\.\d+)?)$/);if(Me){const tt=vt[Me[1]]||`${parseFloat(Me[1])*.25}rem`;a.right=`-${tt}`;continue}if(d==="bottom-0"){a.bottom="0";continue}if(d==="bottom-auto"){a.bottom="auto";continue}if(d==="bottom-full"){a.bottom="100%";continue}const Gt=d.match(/^bottom-(\d+(?:\.\d+)?)$/);if(Gt){a.bottom=vt[Gt[1]]||`${parseFloat(Gt[1])*.25}rem`;continue}const Xs=d.match(/^-bottom-(\d+(?:\.\d+)?)$/);if(Xs){const tt=vt[Xs[1]]||`${parseFloat(Xs[1])*.25}rem`;a.bottom=`-${tt}`;continue}if(d==="left-0"){a.left="0";continue}if(d==="left-auto"){a.left="auto";continue}if(d==="left-full"){a.left="100%";continue}const os=d.match(/^left-(\d+(?:\.\d+)?)$/);if(os){a.left=vt[os[1]]||`${parseFloat(os[1])*.25}rem`;continue}const In=d.match(/^-left-(\d+(?:\.\d+)?)$/);if(In){const tt=vt[In[1]]||`${parseFloat(In[1])*.25}rem`;a.left=`-${tt}`;continue}if(d==="overflow-hidden"){a.overflow="hidden";continue}if(d==="overflow-auto"){a.overflow="auto";continue}if(d==="overflow-scroll"){a.overflow="scroll";continue}if(d==="overflow-visible"){a.overflow="visible";continue}if(d==="overflow-x-auto"){a.overflowX="auto";continue}if(d==="overflow-y-auto"){a.overflowY="auto";continue}if(d==="overflow-x-hidden"){a.overflowX="hidden";continue}if(d==="overflow-y-hidden"){a.overflowY="hidden";continue}if(d==="overflow-x-scroll"){a.overflowX="scroll";continue}if(d==="overflow-y-scroll"){a.overflowY="scroll";continue}if(d==="object-cover"){a.objectFit="cover";continue}if(d==="object-contain"){a.objectFit="contain";continue}if(d==="object-fill"){a.objectFit="fill";continue}if(d==="object-center"){a.objectPosition="center";continue}if(d==="z-0"){a.zIndex=0;continue}if(d==="z-10"){a.zIndex=10;continue}if(d==="z-20"){a.zIndex=20;continue}if(d==="z-30"){a.zIndex=30;continue}if(d==="z-40"){a.zIndex=40;continue}if(d==="z-50"){a.zIndex=50;continue}const Pt=d.match(/^opacity-(\d+)$/);if(Pt){a.opacity=parseInt(Pt[1])/100;continue}const St=d.match(/^text-(xs|sm|base|lg|xl|[2-9]xl)$/);if(St){const tt=cS[St[1]];tt&&(a.fontSize=tt.fontSize,a.lineHeight=tt.lineHeight);continue}const Dn=d.match(/^text-([\w-]+)(?:\/([\d]+))?$/);if(Dn&&!d.startsWith("text-center")&&!d.startsWith("text-left")&&!d.startsWith("text-right")){const tt=Dn[1],Yt=Dn[2],le=r?c[tt]:{black:"#e5e7eb","gray-600":"#9ca3af","gray-700":"#d1d5db","gray-800":"#e5e7eb","gray-900":"#f3f4f6","slate-700":"#cbd5e1","slate-800":"#e2e8f0","slate-900":"#f1f5f9"}[tt]||c[tt];le&&(Yt?a.color=Gn(le,parseInt(Yt)/100):a.color=le);continue}if(d==="bg-clip-text"){a.WebkitBackgroundClip="text",a.backgroundClip="text",a.WebkitTextFillColor="transparent";continue}if(d==="bg-fixed"){a.backgroundAttachment="fixed";continue}if(d==="bg-scroll"){a.backgroundAttachment="scroll";continue}const Ln=d.match(/^bg-([\w-]+)(?:\/([\d]+))?$/);if(Ln&&!d.startsWith("bg-gradient")){const tt=Ln[1],Yt=Ln[2],le=r?c[tt]:{white:"#1f2937","gray-50":"#1f2937","gray-100":"#1f2937","gray-200":"#374151","gray-300":"#4b5563","slate-50":"#1f2937","slate-100":"#1f2937","slate-200":"#334155"}[tt]||c[tt];le&&(Yt?a.backgroundColor=Gn(le,parseInt(Yt)/100):a.backgroundColor=le);continue}if(d==="bg-gradient-to-t"){u="to top";continue}if(d==="bg-gradient-to-tr"){u="to top right";continue}if(d==="bg-gradient-to-r"){u="to right";continue}if(d==="bg-gradient-to-br"){u="to bottom right";continue}if(d==="bg-gradient-to-b"){u="to bottom";continue}if(d==="bg-gradient-to-bl"){u="to bottom left";continue}if(d==="bg-gradient-to-l"){u="to left";continue}if(d==="bg-gradient-to-tl"){u="to top left";continue}const Ze=d.match(/^from-([\w-]+)(?:\/([\d]+))?$/);if(Ze){const tt=Ze[1],Yt=Ze[2],It=c[tt];It&&(f=Yt?Gn(It,parseInt(Yt)/100):It);continue}const as=d.match(/^via-([\w-]+)(?:\/([\d]+))?$/);if(as){const tt=as[1],Yt=as[2],It=c[tt];It&&(p=Yt?Gn(It,parseInt(Yt)/100):It);continue}const Qs=d.match(/^to-([\w-]+)(?:\/([\d]+))?$/);if(Qs){const tt=Qs[1],Yt=Qs[2],It=c[tt];It&&(g=Yt?Gn(It,parseInt(Yt)/100):It);continue}const ls=d.match(/^p-(\d+(?:\.\d+)?)$/);if(ls){a.padding=vt[ls[1]]||`${parseFloat(ls[1])*.25}rem`;continue}const tn=d.match(/^px-(\d+(?:\.\d+)?)$/);if(tn){const tt=vt[tn[1]]||`${parseFloat(tn[1])*.25}rem`;a.paddingLeft=tt,a.paddingRight=tt;continue}const cs=d.match(/^py-(\d+(?:\.\d+)?)$/);if(cs){const tt=vt[cs[1]]||`${parseFloat(cs[1])*.25}rem`;a.paddingTop=tt,a.paddingBottom=tt;continue}const hs=d.match(/^pt-(\d+(?:\.\d+)?)$/);if(hs){a.paddingTop=vt[hs[1]]||`${parseFloat(hs[1])*.25}rem`;continue}const us=d.match(/^pr-(\d+(?:\.\d+)?)$/);if(us){a.paddingRight=vt[us[1]]||`${parseFloat(us[1])*.25}rem`;continue}const Js=d.match(/^pb-(\d+(?:\.\d+)?)$/);if(Js){a.paddingBottom=vt[Js[1]]||`${parseFloat(Js[1])*.25}rem`;continue}const Ks=d.match(/^pl-(\d+(?:\.\d+)?)$/);if(Ks){a.paddingLeft=vt[Ks[1]]||`${parseFloat(Ks[1])*.25}rem`;continue}const Ee=d.match(/^m-(\d+(?:\.\d+)?)$/);if(Ee){a.margin=vt[Ee[1]]||`${parseFloat(Ee[1])*.25}rem`;continue}const zn=d.match(/^mx-(\d+(?:\.\d+)?|auto)$/);if(zn){const tt=zn[1]==="auto"?"auto":vt[zn[1]]||`${parseFloat(zn[1])*.25}rem`;a.marginLeft=tt,a.marginRight=tt;continue}const Be=d.match(/^my-(\d+(?:\.\d+)?|auto)$/);if(Be){const tt=Be[1]==="auto"?"auto":vt[Be[1]]||`${parseFloat(Be[1])*.25}rem`;a.marginTop=tt,a.marginBottom=tt;continue}const dn=d.match(/^mt-(\d+(?:\.\d+)?|auto)$/);if(dn){a.marginTop=dn[1]==="auto"?"auto":vt[dn[1]]||`${parseFloat(dn[1])*.25}rem`;continue}const Fn=d.match(/^mr-(\d+(?:\.\d+)?|auto)$/);if(Fn){a.marginRight=Fn[1]==="auto"?"auto":vt[Fn[1]]||`${parseFloat(Fn[1])*.25}rem`;continue}const Zs=d.match(/^mb-(\d+(?:\.\d+)?)$/);if(Zs){a.marginBottom=vt[Zs[1]]||`${parseFloat(Zs[1])*.25}rem`;continue}const ds=d.match(/^ml-(\d+(?:\.\d+)?|auto)$/);if(ds){a.marginLeft=ds[1]==="auto"?"auto":vt[ds[1]]||`${parseFloat(ds[1])*.25}rem`;continue}if(d==="mt-auto"){a.marginTop="auto";continue}const zt=d.match(/^gap-(\d+(?:\.\d+)?)$/);if(zt){a.gap=vt[zt[1]]||`${parseFloat(zt[1])*.25}rem`;continue}const se=d.match(/^gap-x-(\d+(?:\.\d+)?)$/);if(se){a.columnGap=vt[se[1]]||`${parseFloat(se[1])*.25}rem`;continue}const ti=d.match(/^gap-y-(\d+(?:\.\d+)?)$/);if(ti){a.rowGap=vt[ti[1]]||`${parseFloat(ti[1])*.25}rem`;continue}const fs=d.match(/^space-x-(\d+(?:\.\d+)?)$/);if(fs){a.columnGap=vt[fs[1]]||`${parseFloat(fs[1])*.25}rem`;continue}const ms=d.match(/^space-y-(\d+(?:\.\d+)?)$/);if(ms){a.rowGap=vt[ms[1]]||`${parseFloat(ms[1])*.25}rem`;continue}const Bn=d.match(/^space-x-\[([^\]]+)\]$/);if(Bn){a.columnGap=Bn[1];continue}const _e=d.match(/^space-y-\[([^\]]+)\]$/);if(_e){a.rowGap=_e[1];continue}const Wn=d.match(/^grid-cols-(\d+)$/);if(Wn){a.gridTemplateColumns=`repeat(${Wn[1]}, minmax(0, 1fr))`;continue}if(d==="rounded"){a.borderRadius="0.25rem";continue}if(d==="rounded-none"){a.borderRadius="0";continue}if(d==="rounded-sm"){a.borderRadius="0.125rem";continue}if(d==="rounded-md"){a.borderRadius="0.375rem";continue}if(d==="rounded-lg"){a.borderRadius="0.5rem";continue}if(d==="rounded-xl"){a.borderRadius="0.75rem";continue}if(d==="rounded-2xl"){a.borderRadius="1rem";continue}if(d==="rounded-3xl"){a.borderRadius="1.5rem";continue}if(d==="rounded-full"){a.borderRadius="9999px";continue}if(d==="border"){a.borderWidth="1px",a.borderStyle="solid";continue}if(d==="border-0"){a.borderWidth="0";continue}if(d==="border-2"){a.borderWidth="2px",a.borderStyle="solid";continue}if(d==="border-t"){a.borderTopWidth="1px",a.borderStyle="solid";continue}if(d==="border-b"){a.borderBottomWidth="1px",a.borderStyle="solid";continue}if(d==="border-l"){a.borderLeftWidth="1px",a.borderStyle="solid";continue}if(d==="border-r"){a.borderRightWidth="1px",a.borderStyle="solid";continue}const Wi=d.match(/^border-t-(\d+)$/);if(Wi){a.borderTopWidth=`${Wi[1]}px`,a.borderStyle="solid";continue}const ps=d.match(/^border-b-(\d+)$/);if(ps){a.borderBottomWidth=`${ps[1]}px`,a.borderStyle="solid";continue}const We=d.match(/^border-l-(\d+)$/);if(We){a.borderLeftWidth=`${We[1]}px`,a.borderStyle="solid";continue}const fn=d.match(/^border-r-(\d+)$/);if(fn){a.borderRightWidth=`${fn[1]}px`,a.borderStyle="solid";continue}const Ot=d.match(/^border-(\d+)$/);if(Ot){a.borderWidth=`${Ot[1]}px`,a.borderStyle="solid";continue}const en=d.match(/^border-([\w-]+)(?:\/([\d]+))?$/);if(en&&!d.match(/^border-[trbl]$/)){const tt=en[1],Yt=en[2],le=r?c[tt]:{white:"#374151","gray-100":"#374151","gray-200":"#374151","gray-300":"#4b5563","slate-100":"#334155","slate-200":"#334155","slate-300":"#475569"}[tt]||c[tt];le&&(a.borderColor=Yt?Gn(le,parseInt(Yt)/100):le);continue}if(d==="shadow"){a.boxShadow="0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-sm"){a.boxShadow="0 1px 2px 0 rgb(0 0 0 / 0.05)";continue}if(d==="shadow-md"){a.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-lg"){a.boxShadow="0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-xl"){a.boxShadow="0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-2xl"){a.boxShadow="0 25px 50px -12px rgb(0 0 0 / 0.25)";continue}if(d==="shadow-none"){a.boxShadow="none";continue}if(d==="ring"){a.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.5)";continue}if(d==="ring-0"){a.boxShadow="0 0 0 0px transparent";continue}if(d==="ring-1"){a.boxShadow="0 0 0 1px rgba(59, 130, 246, 0.5)";continue}if(d==="ring-2"){a.boxShadow="0 0 0 2px rgba(59, 130, 246, 0.5)";continue}const Ft=d.match(/^ring-([\w-]+)(?:\/([\d]+))?$/);if(Ft&&!d.match(/^ring-\d$/)){const tt=Ft[1],Yt=Ft[2],It=c[tt];if(It){const le=Yt?parseInt(Yt)/100:1;a.boxShadow&&a.boxShadow.includes("0 0 0")&&(a.boxShadow=a.boxShadow.replace(/rgba\([^)]+\)/,Gn(It,le)))}continue}if(d==="backdrop-blur"){a.backdropFilter="blur(8px)";continue}if(d==="backdrop-blur-none"){a.backdropFilter="blur(0)";continue}if(d==="backdrop-blur-sm"){a.backdropFilter="blur(4px)";continue}if(d==="backdrop-blur-md"){a.backdropFilter="blur(12px)";continue}if(d==="backdrop-blur-lg"){a.backdropFilter="blur(16px)";continue}if(d==="backdrop-blur-xl"){a.backdropFilter="blur(24px)";continue}if(d==="backdrop-blur-2xl"){a.backdropFilter="blur(40px)";continue}if(d==="backdrop-blur-3xl"){a.backdropFilter="blur(64px)";continue}if(d==="blur"){a.filter="blur(8px)";continue}if(d==="blur-none"){a.filter="blur(0)";continue}if(d==="blur-sm"){a.filter="blur(4px)";continue}if(d==="blur-md"){a.filter="blur(12px)";continue}if(d==="blur-lg"){a.filter="blur(16px)";continue}if(d==="blur-xl"){a.filter="blur(24px)";continue}if(d==="blur-2xl"){a.filter="blur(40px)";continue}if(d==="blur-3xl"){a.filter="blur(64px)";continue}const He=d.match(/^scale-(\d+)$/);if(He){const tt=parseInt(He[1])/100;a.transform=`scale(${tt})`;continue}const nn=d.match(/^scale-x-(\d+)$/);if(nn){const tt=parseInt(nn[1])/100;a.transform=`scaleX(${tt})`;continue}const gs=d.match(/^scale-y-(\d+)$/);if(gs){const tt=parseInt(gs[1])/100;a.transform=`scaleY(${tt})`;continue}const ys=d.match(/^rotate-(\d+)$/);if(ys){a.transform=`rotate(${ys[1]}deg)`;continue}const bs=d.match(/^-rotate-(\d+)$/);if(bs){a.transform=`rotate(-${bs[1]}deg)`;continue}const mn=d.match(/^translate-x-(\d+(?:\.\d+)?)$/);if(mn){const tt=vt[mn[1]]||`${parseFloat(mn[1])*.25}rem`;a.transform=`translateX(${tt})`;continue}const pn=d.match(/^-translate-x-(\d+(?:\.\d+)?)$/);if(pn){const tt=vt[pn[1]]||`${parseFloat(pn[1])*.25}rem`;a.transform=`translateX(-${tt})`;continue}const Ie=d.match(/^translate-y-(\d+(?:\.\d+)?)$/);if(Ie){const tt=vt[Ie[1]]||`${parseFloat(Ie[1])*.25}rem`;a.transform=`translateY(${tt})`;continue}const ie=d.match(/^-translate-y-(\d+(?:\.\d+)?)$/);if(ie){const tt=vt[ie[1]]||`${parseFloat(ie[1])*.25}rem`;a.transform=`translateY(-${tt})`;continue}if(d==="translate-x-full"){a.transform="translateX(100%)";continue}if(d==="-translate-x-full"){a.transform="translateX(-100%)";continue}if(d==="translate-y-full"){a.transform="translateY(100%)";continue}if(d==="-translate-y-full"){a.transform="translateY(-100%)";continue}if(d==="translate-x-1/2"){a.transform="translateX(50%)";continue}if(d==="-translate-x-1/2"){a.transform="translateX(-50%)";continue}if(d==="translate-y-1/2"){a.transform="translateY(50%)";continue}if(d==="-translate-y-1/2"){a.transform="translateY(-50%)";continue}if(d.startsWith("animate-")||d.startsWith("divide-")||d.startsWith("group-"))continue;if(d==="leading-none"){a.lineHeight="1";continue}if(d==="leading-tight"){a.lineHeight="1.25";continue}if(d==="leading-snug"){a.lineHeight="1.375";continue}if(d==="leading-normal"){a.lineHeight="1.5";continue}if(d==="leading-relaxed"){a.lineHeight="1.625";continue}if(d==="leading-loose"){a.lineHeight="2";continue}if(d==="tracking-tighter"){a.letterSpacing="-0.05em";continue}if(d==="tracking-tight"){a.letterSpacing="-0.025em";continue}if(d==="tracking-normal"){a.letterSpacing="0em";continue}if(d==="tracking-wide"){a.letterSpacing="0.025em";continue}if(d==="tracking-wider"){a.letterSpacing="0.05em";continue}if(d==="tracking-widest"){a.letterSpacing="0.1em";continue}const re=d.match(/^tracking-\[(.+)\]$/);if(re){a.letterSpacing=re[1];continue}const sn=d.match(/^w-\[(.+)\]$/);if(sn){a.width=sn[1];continue}const Wt=d.match(/^h-\[(.+)\]$/);if(Wt){a.height=Wt[1];continue}const Vi=d.match(/^min-h-\[(.+)\]$/);if(Vi){a.minHeight=Vi[1];continue}const gn=d.match(/^max-w-\[(.+)\]$/);if(gn){a.maxWidth=gn[1];continue}}return u&&f&&(p?a.backgroundImage=`linear-gradient(${u}, ${f}, ${p}, ${g||f})`:g?a.backgroundImage=`linear-gradient(${u}, ${f}, ${g})`:a.backgroundImage=`linear-gradient(${u}, ${f}, transparent)`),a}function Gn(e,t){const n=parseInt(e.slice(1,3),16),s=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${n}, ${s}, ${i}, ${t})`}const zu={margin:0,padding:0,boxSizing:"border-box",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};function hS(e){return`
|
|
23
|
+
`)}const uS={slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},Aa={transparent:"transparent",current:"currentColor",inherit:"inherit",black:"#000000",white:"#ffffff",primary:"#3b82f6",secondary:"#64748b",accent:"#ec4899",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"};for(const[e,t]of Object.entries(uS))for(const[n,s]of Object.entries(t))Aa[`${e}-${n}`]=s;const vt={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},dS={xs:{fontSize:"0.75rem",lineHeight:"1rem"},sm:{fontSize:"0.875rem",lineHeight:"1.25rem"},base:{fontSize:"1rem",lineHeight:"1.5rem"},lg:{fontSize:"1.125rem",lineHeight:"1.75rem"},xl:{fontSize:"1.25rem",lineHeight:"1.75rem"},"2xl":{fontSize:"1.5rem",lineHeight:"2rem"},"3xl":{fontSize:"1.875rem",lineHeight:"2.25rem"},"4xl":{fontSize:"2.25rem",lineHeight:"2.5rem"},"5xl":{fontSize:"3rem",lineHeight:"1"},"6xl":{fontSize:"3.75rem",lineHeight:"1"},"7xl":{fontSize:"4.5rem",lineHeight:"1"},"8xl":{fontSize:"6rem",lineHeight:"1"},"9xl":{fontSize:"8rem",lineHeight:"1"}};function Tl(e,t,n=!0){if(!e)return{};e=String(e);const{colorMode:s,...i}=t||{},r=s==="light",o=e.match(/(?:^|\s)dark:([^\s]+)/g)||[],l=e.replace(/(?:^|\s)dark:[^\s]+/g," ").replace(/\s+/g," ").trim();!r&&o.length?e=l?`${l} ${o.map(d=>d.trim().replace(/^dark:/,"")).join(" ")}`:o.map(d=>d.trim().replace(/^dark:/,"")).join(" "):e=l;const c=i?{...Aa,...Object.fromEntries(Object.entries(i).filter(([,d])=>d))}:Aa;r&&n&&(c.white="#000000",c.black="#ffffff",c["gray-300"]="#4b5563",c["gray-400"]="#374151",c["gray-500"]="#374151",c["gray-600"]="#1f2937",c["gray-700"]="#111827",c["gray-800"]="#0f172a",c["slate-300"]="#475569",c["slate-400"]="#334155",c["slate-500"]="#334155",c["slate-600"]="#1e293b");const h=e.split(/\s+/).filter(Boolean),a={};let u="",f="",p="",g="";for(let d of h){if(d.startsWith("hover:")||d.startsWith("focus:")||d.startsWith("active:")||d.startsWith("group-hover:")||d==="transition"||d==="transition-all"||d==="transition-colors"||d==="transition-opacity"||d==="transition-transform"||d.startsWith("duration-")||d.startsWith("ease-")||d==="cursor-pointer"||d==="grayscale"||((d.startsWith("sm:")||d.startsWith("md:")||d.startsWith("lg:")||d.startsWith("xl:")||d.startsWith("2xl:"))&&(d=d.replace(/^(sm:|md:|lg:|xl:|2xl:)/,"")),d.startsWith("placeholder-"))||d.startsWith("disabled:"))continue;const w=d.match(/^bg-\[([^\]]+)\]$/);if(w){const tt=w[1];tt.startsWith("url(")?a.backgroundImage=tt:a.backgroundColor=tt;continue}const C=d.match(/^text-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\)|hsl[a]?\([^)]+\))\]$/);if(C){a.color=C[1];continue}const x=d.match(/^text-\[(\d+(?:\.\d+)?(?:px|rem|em|%))\]$/);if(x){a.fontSize=x[1];continue}const k=d.match(/^w-\[([^\]]+)\]$/);if(k){a.width=k[1];continue}const S=d.match(/^h-\[([^\]]+)\]$/);if(S){a.height=S[1];continue}const T=d.match(/^min-w-\[([^\]]+)\]$/);if(T){a.minWidth=T[1];continue}const P=d.match(/^max-w-\[([^\]]+)\]$/);if(P){a.maxWidth=P[1];continue}const I=d.match(/^min-h-\[([^\]]+)\]$/);if(I){a.minHeight=I[1];continue}const L=d.match(/^max-h-\[([^\]]+)\]$/);if(L){a.maxHeight=L[1];continue}const O=d.match(/^p-\[([^\]]+)\]$/);if(O){a.padding=O[1];continue}const H=d.match(/^px-\[([^\]]+)\]$/);if(H){a.paddingLeft=H[1],a.paddingRight=H[1];continue}const U=d.match(/^py-\[([^\]]+)\]$/);if(U){a.paddingTop=U[1],a.paddingBottom=U[1];continue}const q=d.match(/^pt-\[([^\]]+)\]$/);if(q){a.paddingTop=q[1];continue}const X=d.match(/^pr-\[([^\]]+)\]$/);if(X){a.paddingRight=X[1];continue}const j=d.match(/^pb-\[([^\]]+)\]$/);if(j){a.paddingBottom=j[1];continue}const D=d.match(/^pl-\[([^\]]+)\]$/);if(D){a.paddingLeft=D[1];continue}const V=d.match(/^m-\[([^\]]+)\]$/);if(V){a.margin=V[1];continue}const J=d.match(/^mx-\[([^\]]+)\]$/);if(J){a.marginLeft=J[1],a.marginRight=J[1];continue}const nt=d.match(/^my-\[([^\]]+)\]$/);if(nt){a.marginTop=nt[1],a.marginBottom=nt[1];continue}const it=d.match(/^mt-\[([^\]]+)\]$/);if(it){a.marginTop=it[1];continue}const Q=d.match(/^mr-\[([^\]]+)\]$/);if(Q){a.marginRight=Q[1];continue}const ut=d.match(/^mb-\[([^\]]+)\]$/);if(ut){a.marginBottom=ut[1];continue}const Ct=d.match(/^ml-\[([^\]]+)\]$/);if(Ct){a.marginLeft=Ct[1];continue}const ft=d.match(/^gap-\[([^\]]+)\]$/);if(ft){a.gap=ft[1];continue}const Dt=d.match(/^gap-x-\[([^\]]+)\]$/);if(Dt){a.columnGap=Dt[1];continue}const qt=d.match(/^gap-y-\[([^\]]+)\]$/);if(qt){a.rowGap=qt[1];continue}const ne=d.match(/^rounded-\[([^\]]+)\]$/);if(ne){a.borderRadius=ne[1];continue}const te=d.match(/^border-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\))\]$/);if(te){a.borderColor=te[1];continue}const mt=d.match(/^border-\[(\d+(?:\.\d+)?(?:px)?)\]$/);if(mt){a.borderWidth=mt[1];continue}const he=d.match(/^top-\[([^\]]+)\]$/);if(he){a.top=he[1];continue}const Pe=d.match(/^right-\[([^\]]+)\]$/);if(Pe){a.right=Pe[1];continue}const ae=d.match(/^bottom-\[([^\]]+)\]$/);if(ae){a.bottom=ae[1];continue}const In=d.match(/^left-\[([^\]]+)\]$/);if(In){a.left=In[1];continue}const Ys=d.match(/^inset-\[([^\]]+)\]$/);if(Ys){a.inset=Ys[1];continue}const Oe=d.match(/^z-\[([^\]]+)\]$/);if(Oe){a.zIndex=parseInt(Oe[1])||Oe[1];continue}const xe=d.match(/^opacity-\[([^\]]+)\]$/);if(xe){a.opacity=parseFloat(xe[1]);continue}const bt=d.match(/^leading-\[([^\]]+)\]$/);if(bt){a.lineHeight=bt[1];continue}if(d==="flex"){a.display="flex";continue}if(d==="grid"){a.display="grid";continue}if(d==="block"){a.display="block";continue}if(d==="inline"){a.display="inline";continue}if(d==="inline-flex"){a.display="inline-flex";continue}if(d==="inline-block"){a.display="inline-block";continue}if(d==="hidden"){a.display="none";continue}if(d==="flex-col"){a.flexDirection="column";continue}if(d==="flex-row"){a.flexDirection="row";continue}if(d==="flex-wrap"){a.flexWrap="wrap";continue}if(d==="flex-nowrap"){a.flexWrap="nowrap";continue}if(d==="flex-col-reverse"){a.flexDirection="column-reverse";continue}if(d==="flex-row-reverse"){a.flexDirection="row-reverse";continue}if(d==="flex-1"){a.flex="1 1 0%";continue}if(d==="flex-auto"){a.flex="1 1 auto";continue}if(d==="flex-initial"){a.flex="0 1 auto";continue}if(d==="flex-none"){a.flex="none";continue}if(d==="grow"){a.flexGrow=1;continue}if(d==="grow-0"){a.flexGrow=0;continue}if(d==="shrink"){a.flexShrink=1;continue}if(d==="shrink-0"){a.flexShrink=0;continue}if(d==="items-start"){a.alignItems="flex-start";continue}if(d==="items-center"){a.alignItems="center";continue}if(d==="items-end"){a.alignItems="flex-end";continue}if(d==="items-stretch"){a.alignItems="stretch";continue}if(d==="items-baseline"){a.alignItems="baseline";continue}if(d==="justify-start"){a.justifyContent="flex-start";continue}if(d==="justify-center"){a.justifyContent="center";continue}if(d==="justify-end"){a.justifyContent="flex-end";continue}if(d==="justify-between"){a.justifyContent="space-between";continue}if(d==="justify-around"){a.justifyContent="space-around";continue}if(d==="justify-evenly"){a.justifyContent="space-evenly";continue}if(d==="justify-items-start"){a.justifyItems="start";continue}if(d==="justify-items-center"){a.justifyItems="center";continue}if(d==="justify-items-end"){a.justifyItems="end";continue}if(d==="justify-items-stretch"){a.justifyItems="stretch";continue}if(d==="self-auto"){a.alignSelf="auto";continue}if(d==="self-start"){a.alignSelf="flex-start";continue}if(d==="self-center"){a.alignSelf="center";continue}if(d==="self-end"){a.alignSelf="flex-end";continue}if(d==="self-stretch"){a.alignSelf="stretch";continue}if(d==="self-baseline"){a.alignSelf="baseline";continue}if(d==="justify-self-auto"){a.justifySelf="auto";continue}if(d==="justify-self-start"){a.justifySelf="start";continue}if(d==="justify-self-center"){a.justifySelf="center";continue}if(d==="justify-self-end"){a.justifySelf="end";continue}if(d==="justify-self-stretch"){a.justifySelf="stretch";continue}if(d==="place-content-center"){a.placeContent="center";continue}if(d==="place-content-start"){a.placeContent="start";continue}if(d==="place-content-end"){a.placeContent="end";continue}if(d==="place-content-between"){a.placeContent="space-between";continue}if(d==="place-content-around"){a.placeContent="space-around";continue}if(d==="place-content-evenly"){a.placeContent="space-evenly";continue}if(d==="place-content-stretch"){a.placeContent="stretch";continue}if(d==="place-items-start"){a.placeItems="start";continue}if(d==="place-items-center"){a.placeItems="center";continue}if(d==="place-items-end"){a.placeItems="end";continue}if(d==="place-items-stretch"){a.placeItems="stretch";continue}if(d==="text-left"){a.textAlign="left";continue}if(d==="text-center"){a.textAlign="center";continue}if(d==="text-right"){a.textAlign="right";continue}if(d==="text-justify"){a.textAlign="justify";continue}if(d==="text-start"){a.textAlign="start";continue}if(d==="text-end"){a.textAlign="end";continue}if(d==="whitespace-normal"){a.whiteSpace="normal";continue}if(d==="whitespace-nowrap"){a.whiteSpace="nowrap";continue}if(d==="whitespace-pre"){a.whiteSpace="pre";continue}if(d==="whitespace-pre-line"){a.whiteSpace="pre-line";continue}if(d==="whitespace-pre-wrap"){a.whiteSpace="pre-wrap";continue}if(d==="whitespace-break-spaces"){a.whiteSpace="break-spaces";continue}if(d==="break-normal"){a.wordBreak="normal",a.overflowWrap="normal";continue}if(d==="break-words"){a.overflowWrap="break-word";continue}if(d==="break-all"){a.wordBreak="break-all";continue}if(d==="break-keep"){a.wordBreak="keep-all";continue}if(d==="truncate"){a.overflow="hidden",a.textOverflow="ellipsis",a.whiteSpace="nowrap";continue}if(d==="text-ellipsis"){a.textOverflow="ellipsis";continue}if(d==="text-clip"){a.textOverflow="clip";continue}if(d==="underline"){a.textDecoration="underline";continue}if(d==="overline"){a.textDecoration="overline";continue}if(d==="line-through"){a.textDecoration="line-through";continue}if(d==="no-underline"){a.textDecoration="none";continue}if(d==="uppercase"){a.textTransform="uppercase";continue}if(d==="lowercase"){a.textTransform="lowercase";continue}if(d==="capitalize"){a.textTransform="capitalize";continue}if(d==="normal-case"){a.textTransform="none";continue}if(d==="italic"){a.fontStyle="italic";continue}if(d==="not-italic"){a.fontStyle="normal";continue}if(d==="font-thin"){a.fontWeight=100;continue}if(d==="font-extralight"){a.fontWeight=200;continue}if(d==="font-light"){a.fontWeight=300;continue}if(d==="font-normal"){a.fontWeight=400;continue}if(d==="font-medium"){a.fontWeight=500;continue}if(d==="font-semibold"){a.fontWeight=600;continue}if(d==="font-bold"){a.fontWeight=700;continue}if(d==="font-extrabold"){a.fontWeight=800;continue}if(d==="font-black"){a.fontWeight=900;continue}if(d==="w-full"){a.width="100%";continue}if(d==="w-screen"){a.width="100vw";continue}if(d==="w-auto"){a.width="auto";continue}if(d==="w-fit"){a.width="fit-content";continue}if(d==="w-min"){a.width="min-content";continue}if(d==="w-max"){a.width="max-content";continue}const Rt=d.match(/^w-(\d+(?:\.\d+)?)$/);if(Rt){a.width=vt[Rt[1]]||`${parseFloat(Rt[1])*.25}rem`;continue}const Lt=d.match(/^w-(\d+)\/(\d+)$/);if(Lt){const tt=parseInt(Lt[1])/parseInt(Lt[2])*100;a.width=`${tt}%`;continue}if(d==="h-full"){a.height="100%";continue}if(d==="h-screen"){a.height="100vh";continue}if(d==="h-auto"){a.height="auto";continue}if(d==="h-fit"){a.height="fit-content";continue}if(d==="h-min"){a.height="min-content";continue}if(d==="h-max"){a.height="max-content";continue}const kt=d.match(/^h-(\d+(?:\.\d+)?)$/);if(kt){a.height=vt[kt[1]]||`${parseFloat(kt[1])*.25}rem`;continue}const yt=d.match(/^h-(\d+)\/(\d+)$/);if(yt){const tt=parseInt(yt[1])/parseInt(yt[2])*100;a.height=`${tt}%`;continue}if(d==="min-h-screen"){a.minHeight="100vh";continue}if(d==="min-h-full"){a.minHeight="100%";continue}if(d==="min-h-0"){a.minHeight="0";continue}if(d==="min-h-fit"){a.minHeight="fit-content";continue}const wt=d.match(/^min-h-(\d+(?:\.\d+)?)$/);if(wt){a.minHeight=vt[wt[1]]||`${parseFloat(wt[1])*.25}rem`;continue}if(d==="min-w-0"){a.minWidth="0";continue}if(d==="min-w-full"){a.minWidth="100%";continue}if(d==="min-w-fit"){a.minWidth="fit-content";continue}const gt=d.match(/^min-w-(\d+(?:\.\d+)?)$/);if(gt){a.minWidth=vt[gt[1]]||`${parseFloat(gt[1])*.25}rem`;continue}if(d==="max-w-none"){a.maxWidth="none";continue}if(d==="max-w-xs"){a.maxWidth="20rem";continue}if(d==="max-w-sm"){a.maxWidth="24rem";continue}if(d==="max-w-md"){a.maxWidth="28rem";continue}if(d==="max-w-lg"){a.maxWidth="32rem";continue}if(d==="max-w-xl"){a.maxWidth="36rem";continue}if(d==="max-w-2xl"){a.maxWidth="42rem";continue}if(d==="max-w-3xl"){a.maxWidth="48rem";continue}if(d==="max-w-4xl"){a.maxWidth="56rem";continue}if(d==="max-w-5xl"){a.maxWidth="64rem";continue}if(d==="max-w-6xl"){a.maxWidth="72rem";continue}if(d==="max-w-7xl"){a.maxWidth="80rem";continue}if(d==="max-w-full"){a.maxWidth="100%";continue}if(d==="max-w-prose"){a.maxWidth="65ch";continue}if(d==="max-w-screen-sm"){a.maxWidth="640px";continue}if(d==="max-w-screen-md"){a.maxWidth="768px";continue}if(d==="max-w-screen-lg"){a.maxWidth="1024px";continue}if(d==="max-w-screen-xl"){a.maxWidth="1280px";continue}if(d==="max-w-screen-2xl"){a.maxWidth="1536px";continue}if(d==="max-h-none"){a.maxHeight="none";continue}if(d==="max-h-full"){a.maxHeight="100%";continue}if(d==="max-h-screen"){a.maxHeight="100vh";continue}if(d==="max-h-fit"){a.maxHeight="fit-content";continue}const Xt=d.match(/^max-h-(\d+(?:\.\d+)?)$/);if(Xt){a.maxHeight=vt[Xt[1]]||`${parseFloat(Xt[1])*.25}rem`;continue}if(d==="relative"){a.position="relative";continue}if(d==="absolute"){a.position="absolute";continue}if(d==="fixed"){a.position="fixed";continue}if(d==="sticky"){a.position="sticky";continue}if(d==="inset-0"){a.top="0",a.right="0",a.bottom="0",a.left="0";continue}if(d==="inset-auto"){a.top="auto",a.right="auto",a.bottom="auto",a.left="auto";continue}if(d==="inset-x-0"){a.left="0",a.right="0";continue}if(d==="inset-y-0"){a.top="0",a.bottom="0";continue}const Ue=d.match(/^inset-(\d+(?:\.\d+)?)$/);if(Ue){const tt=vt[Ue[1]]||`${parseFloat(Ue[1])*.25}rem`;a.top=tt,a.right=tt,a.bottom=tt,a.left=tt;continue}const ge=d.match(/^inset-x-(\d+(?:\.\d+)?)$/);if(ge){const tt=vt[ge[1]]||`${parseFloat(ge[1])*.25}rem`;a.left=tt,a.right=tt;continue}const ee=d.match(/^inset-y-(\d+(?:\.\d+)?)$/);if(ee){const tt=vt[ee[1]]||`${parseFloat(ee[1])*.25}rem`;a.top=tt,a.bottom=tt;continue}if(d==="top-0"){a.top="0";continue}if(d==="top-auto"){a.top="auto";continue}if(d==="top-full"){a.top="100%";continue}const os=d.match(/^top-(\d+(?:\.\d+)?)$/);if(os){a.top=vt[os[1]]||`${parseFloat(os[1])*.25}rem`;continue}const ue=d.match(/^-top-(\d+(?:\.\d+)?)$/);if(ue){const tt=vt[ue[1]]||`${parseFloat(ue[1])*.25}rem`;a.top=`-${tt}`;continue}if(d==="right-0"){a.right="0";continue}if(d==="right-auto"){a.right="auto";continue}if(d==="right-full"){a.right="100%";continue}const ot=d.match(/^right-(\d+(?:\.\d+)?)$/);if(ot){a.right=vt[ot[1]]||`${parseFloat(ot[1])*.25}rem`;continue}const Me=d.match(/^-right-(\d+(?:\.\d+)?)$/);if(Me){const tt=vt[Me[1]]||`${parseFloat(Me[1])*.25}rem`;a.right=`-${tt}`;continue}if(d==="bottom-0"){a.bottom="0";continue}if(d==="bottom-auto"){a.bottom="auto";continue}if(d==="bottom-full"){a.bottom="100%";continue}const Gt=d.match(/^bottom-(\d+(?:\.\d+)?)$/);if(Gt){a.bottom=vt[Gt[1]]||`${parseFloat(Gt[1])*.25}rem`;continue}const Xs=d.match(/^-bottom-(\d+(?:\.\d+)?)$/);if(Xs){const tt=vt[Xs[1]]||`${parseFloat(Xs[1])*.25}rem`;a.bottom=`-${tt}`;continue}if(d==="left-0"){a.left="0";continue}if(d==="left-auto"){a.left="auto";continue}if(d==="left-full"){a.left="100%";continue}const as=d.match(/^left-(\d+(?:\.\d+)?)$/);if(as){a.left=vt[as[1]]||`${parseFloat(as[1])*.25}rem`;continue}const Dn=d.match(/^-left-(\d+(?:\.\d+)?)$/);if(Dn){const tt=vt[Dn[1]]||`${parseFloat(Dn[1])*.25}rem`;a.left=`-${tt}`;continue}if(d==="overflow-hidden"){a.overflow="hidden";continue}if(d==="overflow-auto"){a.overflow="auto";continue}if(d==="overflow-scroll"){a.overflow="scroll";continue}if(d==="overflow-visible"){a.overflow="visible";continue}if(d==="overflow-x-auto"){a.overflowX="auto";continue}if(d==="overflow-y-auto"){a.overflowY="auto";continue}if(d==="overflow-x-hidden"){a.overflowX="hidden";continue}if(d==="overflow-y-hidden"){a.overflowY="hidden";continue}if(d==="overflow-x-scroll"){a.overflowX="scroll";continue}if(d==="overflow-y-scroll"){a.overflowY="scroll";continue}if(d==="object-cover"){a.objectFit="cover";continue}if(d==="object-contain"){a.objectFit="contain";continue}if(d==="object-fill"){a.objectFit="fill";continue}if(d==="object-center"){a.objectPosition="center";continue}if(d==="z-0"){a.zIndex=0;continue}if(d==="z-10"){a.zIndex=10;continue}if(d==="z-20"){a.zIndex=20;continue}if(d==="z-30"){a.zIndex=30;continue}if(d==="z-40"){a.zIndex=40;continue}if(d==="z-50"){a.zIndex=50;continue}const Pt=d.match(/^opacity-(\d+)$/);if(Pt){a.opacity=parseInt(Pt[1])/100;continue}const St=d.match(/^text-(xs|sm|base|lg|xl|[2-9]xl)$/);if(St){const tt=dS[St[1]];tt&&(a.fontSize=tt.fontSize,a.lineHeight=tt.lineHeight);continue}const Ln=d.match(/^text-([\w-]+)(?:\/([\d]+))?$/);if(Ln&&!d.startsWith("text-center")&&!d.startsWith("text-left")&&!d.startsWith("text-right")){const tt=Ln[1],Yt=Ln[2],le=r?c[tt]:{black:"#e5e7eb","gray-600":"#9ca3af","gray-700":"#d1d5db","gray-800":"#e5e7eb","gray-900":"#f3f4f6","slate-700":"#cbd5e1","slate-800":"#e2e8f0","slate-900":"#f1f5f9"}[tt]||c[tt];le&&(Yt?a.color=Yn(le,parseInt(Yt)/100):a.color=le);continue}if(d==="bg-clip-text"){a.WebkitBackgroundClip="text",a.backgroundClip="text",a.WebkitTextFillColor="transparent";continue}if(d==="bg-fixed"){a.backgroundAttachment="fixed";continue}if(d==="bg-scroll"){a.backgroundAttachment="scroll";continue}const zn=d.match(/^bg-([\w-]+)(?:\/([\d]+))?$/);if(zn&&!d.startsWith("bg-gradient")){const tt=zn[1],Yt=zn[2],le=r?c[tt]:{white:"#1f2937","gray-50":"#1f2937","gray-100":"#1f2937","gray-200":"#374151","gray-300":"#4b5563","slate-50":"#1f2937","slate-100":"#1f2937","slate-200":"#334155"}[tt]||c[tt];le&&(Yt?a.backgroundColor=Yn(le,parseInt(Yt)/100):a.backgroundColor=le);continue}if(d==="bg-gradient-to-t"){u="to top";continue}if(d==="bg-gradient-to-tr"){u="to top right";continue}if(d==="bg-gradient-to-r"){u="to right";continue}if(d==="bg-gradient-to-br"){u="to bottom right";continue}if(d==="bg-gradient-to-b"){u="to bottom";continue}if(d==="bg-gradient-to-bl"){u="to bottom left";continue}if(d==="bg-gradient-to-l"){u="to left";continue}if(d==="bg-gradient-to-tl"){u="to top left";continue}const Ze=d.match(/^from-([\w-]+)(?:\/([\d]+))?$/);if(Ze){const tt=Ze[1],Yt=Ze[2],It=c[tt];It&&(f=Yt?Yn(It,parseInt(Yt)/100):It);continue}const ls=d.match(/^via-([\w-]+)(?:\/([\d]+))?$/);if(ls){const tt=ls[1],Yt=ls[2],It=c[tt];It&&(p=Yt?Yn(It,parseInt(Yt)/100):It);continue}const Qs=d.match(/^to-([\w-]+)(?:\/([\d]+))?$/);if(Qs){const tt=Qs[1],Yt=Qs[2],It=c[tt];It&&(g=Yt?Yn(It,parseInt(Yt)/100):It);continue}const cs=d.match(/^p-(\d+(?:\.\d+)?)$/);if(cs){a.padding=vt[cs[1]]||`${parseFloat(cs[1])*.25}rem`;continue}const tn=d.match(/^px-(\d+(?:\.\d+)?)$/);if(tn){const tt=vt[tn[1]]||`${parseFloat(tn[1])*.25}rem`;a.paddingLeft=tt,a.paddingRight=tt;continue}const hs=d.match(/^py-(\d+(?:\.\d+)?)$/);if(hs){const tt=vt[hs[1]]||`${parseFloat(hs[1])*.25}rem`;a.paddingTop=tt,a.paddingBottom=tt;continue}const us=d.match(/^pt-(\d+(?:\.\d+)?)$/);if(us){a.paddingTop=vt[us[1]]||`${parseFloat(us[1])*.25}rem`;continue}const ds=d.match(/^pr-(\d+(?:\.\d+)?)$/);if(ds){a.paddingRight=vt[ds[1]]||`${parseFloat(ds[1])*.25}rem`;continue}const Js=d.match(/^pb-(\d+(?:\.\d+)?)$/);if(Js){a.paddingBottom=vt[Js[1]]||`${parseFloat(Js[1])*.25}rem`;continue}const Ks=d.match(/^pl-(\d+(?:\.\d+)?)$/);if(Ks){a.paddingLeft=vt[Ks[1]]||`${parseFloat(Ks[1])*.25}rem`;continue}const Ee=d.match(/^m-(\d+(?:\.\d+)?)$/);if(Ee){a.margin=vt[Ee[1]]||`${parseFloat(Ee[1])*.25}rem`;continue}const Fn=d.match(/^mx-(\d+(?:\.\d+)?|auto)$/);if(Fn){const tt=Fn[1]==="auto"?"auto":vt[Fn[1]]||`${parseFloat(Fn[1])*.25}rem`;a.marginLeft=tt,a.marginRight=tt;continue}const Be=d.match(/^my-(\d+(?:\.\d+)?|auto)$/);if(Be){const tt=Be[1]==="auto"?"auto":vt[Be[1]]||`${parseFloat(Be[1])*.25}rem`;a.marginTop=tt,a.marginBottom=tt;continue}const dn=d.match(/^mt-(\d+(?:\.\d+)?|auto)$/);if(dn){a.marginTop=dn[1]==="auto"?"auto":vt[dn[1]]||`${parseFloat(dn[1])*.25}rem`;continue}const Bn=d.match(/^mr-(\d+(?:\.\d+)?|auto)$/);if(Bn){a.marginRight=Bn[1]==="auto"?"auto":vt[Bn[1]]||`${parseFloat(Bn[1])*.25}rem`;continue}const Zs=d.match(/^mb-(\d+(?:\.\d+)?)$/);if(Zs){a.marginBottom=vt[Zs[1]]||`${parseFloat(Zs[1])*.25}rem`;continue}const fs=d.match(/^ml-(\d+(?:\.\d+)?|auto)$/);if(fs){a.marginLeft=fs[1]==="auto"?"auto":vt[fs[1]]||`${parseFloat(fs[1])*.25}rem`;continue}if(d==="mt-auto"){a.marginTop="auto";continue}const zt=d.match(/^gap-(\d+(?:\.\d+)?)$/);if(zt){a.gap=vt[zt[1]]||`${parseFloat(zt[1])*.25}rem`;continue}const se=d.match(/^gap-x-(\d+(?:\.\d+)?)$/);if(se){a.columnGap=vt[se[1]]||`${parseFloat(se[1])*.25}rem`;continue}const ti=d.match(/^gap-y-(\d+(?:\.\d+)?)$/);if(ti){a.rowGap=vt[ti[1]]||`${parseFloat(ti[1])*.25}rem`;continue}const ms=d.match(/^space-x-(\d+(?:\.\d+)?)$/);if(ms){a.columnGap=vt[ms[1]]||`${parseFloat(ms[1])*.25}rem`;continue}const ps=d.match(/^space-y-(\d+(?:\.\d+)?)$/);if(ps){a.rowGap=vt[ps[1]]||`${parseFloat(ps[1])*.25}rem`;continue}const Wn=d.match(/^space-x-\[([^\]]+)\]$/);if(Wn){a.columnGap=Wn[1];continue}const _e=d.match(/^space-y-\[([^\]]+)\]$/);if(_e){a.rowGap=_e[1];continue}const jn=d.match(/^grid-cols-(\d+)$/);if(jn){a.gridTemplateColumns=`repeat(${jn[1]}, minmax(0, 1fr))`;continue}if(d==="rounded"){a.borderRadius="0.25rem";continue}if(d==="rounded-none"){a.borderRadius="0";continue}if(d==="rounded-sm"){a.borderRadius="0.125rem";continue}if(d==="rounded-md"){a.borderRadius="0.375rem";continue}if(d==="rounded-lg"){a.borderRadius="0.5rem";continue}if(d==="rounded-xl"){a.borderRadius="0.75rem";continue}if(d==="rounded-2xl"){a.borderRadius="1rem";continue}if(d==="rounded-3xl"){a.borderRadius="1.5rem";continue}if(d==="rounded-full"){a.borderRadius="9999px";continue}if(d==="border"){a.borderWidth="1px",a.borderStyle="solid";continue}if(d==="border-0"){a.borderWidth="0";continue}if(d==="border-2"){a.borderWidth="2px",a.borderStyle="solid";continue}if(d==="border-t"){a.borderTopWidth="1px",a.borderStyle="solid";continue}if(d==="border-b"){a.borderBottomWidth="1px",a.borderStyle="solid";continue}if(d==="border-l"){a.borderLeftWidth="1px",a.borderStyle="solid";continue}if(d==="border-r"){a.borderRightWidth="1px",a.borderStyle="solid";continue}const Wi=d.match(/^border-t-(\d+)$/);if(Wi){a.borderTopWidth=`${Wi[1]}px`,a.borderStyle="solid";continue}const gs=d.match(/^border-b-(\d+)$/);if(gs){a.borderBottomWidth=`${gs[1]}px`,a.borderStyle="solid";continue}const We=d.match(/^border-l-(\d+)$/);if(We){a.borderLeftWidth=`${We[1]}px`,a.borderStyle="solid";continue}const fn=d.match(/^border-r-(\d+)$/);if(fn){a.borderRightWidth=`${fn[1]}px`,a.borderStyle="solid";continue}const Ot=d.match(/^border-(\d+)$/);if(Ot){a.borderWidth=`${Ot[1]}px`,a.borderStyle="solid";continue}const en=d.match(/^border-([\w-]+)(?:\/([\d]+))?$/);if(en&&!d.match(/^border-[trbl]$/)){const tt=en[1],Yt=en[2],le=r?c[tt]:{white:"#374151","gray-100":"#374151","gray-200":"#374151","gray-300":"#4b5563","slate-100":"#334155","slate-200":"#334155","slate-300":"#475569"}[tt]||c[tt];le&&(a.borderColor=Yt?Yn(le,parseInt(Yt)/100):le);continue}if(d==="shadow"){a.boxShadow="0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-sm"){a.boxShadow="0 1px 2px 0 rgb(0 0 0 / 0.05)";continue}if(d==="shadow-md"){a.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-lg"){a.boxShadow="0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-xl"){a.boxShadow="0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-2xl"){a.boxShadow="0 25px 50px -12px rgb(0 0 0 / 0.25)";continue}if(d==="shadow-none"){a.boxShadow="none";continue}if(d==="ring"){a.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.5)";continue}if(d==="ring-0"){a.boxShadow="0 0 0 0px transparent";continue}if(d==="ring-1"){a.boxShadow="0 0 0 1px rgba(59, 130, 246, 0.5)";continue}if(d==="ring-2"){a.boxShadow="0 0 0 2px rgba(59, 130, 246, 0.5)";continue}const Ft=d.match(/^ring-([\w-]+)(?:\/([\d]+))?$/);if(Ft&&!d.match(/^ring-\d$/)){const tt=Ft[1],Yt=Ft[2],It=c[tt];if(It){const le=Yt?parseInt(Yt)/100:1;a.boxShadow&&a.boxShadow.includes("0 0 0")&&(a.boxShadow=a.boxShadow.replace(/rgba\([^)]+\)/,Yn(It,le)))}continue}if(d==="backdrop-blur"){a.backdropFilter="blur(8px)";continue}if(d==="backdrop-blur-none"){a.backdropFilter="blur(0)";continue}if(d==="backdrop-blur-sm"){a.backdropFilter="blur(4px)";continue}if(d==="backdrop-blur-md"){a.backdropFilter="blur(12px)";continue}if(d==="backdrop-blur-lg"){a.backdropFilter="blur(16px)";continue}if(d==="backdrop-blur-xl"){a.backdropFilter="blur(24px)";continue}if(d==="backdrop-blur-2xl"){a.backdropFilter="blur(40px)";continue}if(d==="backdrop-blur-3xl"){a.backdropFilter="blur(64px)";continue}if(d==="blur"){a.filter="blur(8px)";continue}if(d==="blur-none"){a.filter="blur(0)";continue}if(d==="blur-sm"){a.filter="blur(4px)";continue}if(d==="blur-md"){a.filter="blur(12px)";continue}if(d==="blur-lg"){a.filter="blur(16px)";continue}if(d==="blur-xl"){a.filter="blur(24px)";continue}if(d==="blur-2xl"){a.filter="blur(40px)";continue}if(d==="blur-3xl"){a.filter="blur(64px)";continue}const He=d.match(/^scale-(\d+)$/);if(He){const tt=parseInt(He[1])/100;a.transform=`scale(${tt})`;continue}const nn=d.match(/^scale-x-(\d+)$/);if(nn){const tt=parseInt(nn[1])/100;a.transform=`scaleX(${tt})`;continue}const ys=d.match(/^scale-y-(\d+)$/);if(ys){const tt=parseInt(ys[1])/100;a.transform=`scaleY(${tt})`;continue}const bs=d.match(/^rotate-(\d+)$/);if(bs){a.transform=`rotate(${bs[1]}deg)`;continue}const vs=d.match(/^-rotate-(\d+)$/);if(vs){a.transform=`rotate(-${vs[1]}deg)`;continue}const mn=d.match(/^translate-x-(\d+(?:\.\d+)?)$/);if(mn){const tt=vt[mn[1]]||`${parseFloat(mn[1])*.25}rem`;a.transform=`translateX(${tt})`;continue}const pn=d.match(/^-translate-x-(\d+(?:\.\d+)?)$/);if(pn){const tt=vt[pn[1]]||`${parseFloat(pn[1])*.25}rem`;a.transform=`translateX(-${tt})`;continue}const Ie=d.match(/^translate-y-(\d+(?:\.\d+)?)$/);if(Ie){const tt=vt[Ie[1]]||`${parseFloat(Ie[1])*.25}rem`;a.transform=`translateY(${tt})`;continue}const ie=d.match(/^-translate-y-(\d+(?:\.\d+)?)$/);if(ie){const tt=vt[ie[1]]||`${parseFloat(ie[1])*.25}rem`;a.transform=`translateY(-${tt})`;continue}if(d==="translate-x-full"){a.transform="translateX(100%)";continue}if(d==="-translate-x-full"){a.transform="translateX(-100%)";continue}if(d==="translate-y-full"){a.transform="translateY(100%)";continue}if(d==="-translate-y-full"){a.transform="translateY(-100%)";continue}if(d==="translate-x-1/2"){a.transform="translateX(50%)";continue}if(d==="-translate-x-1/2"){a.transform="translateX(-50%)";continue}if(d==="translate-y-1/2"){a.transform="translateY(50%)";continue}if(d==="-translate-y-1/2"){a.transform="translateY(-50%)";continue}if(d.startsWith("animate-")||d.startsWith("divide-")||d.startsWith("group-"))continue;if(d==="leading-none"){a.lineHeight="1";continue}if(d==="leading-tight"){a.lineHeight="1.25";continue}if(d==="leading-snug"){a.lineHeight="1.375";continue}if(d==="leading-normal"){a.lineHeight="1.5";continue}if(d==="leading-relaxed"){a.lineHeight="1.625";continue}if(d==="leading-loose"){a.lineHeight="2";continue}if(d==="tracking-tighter"){a.letterSpacing="-0.05em";continue}if(d==="tracking-tight"){a.letterSpacing="-0.025em";continue}if(d==="tracking-normal"){a.letterSpacing="0em";continue}if(d==="tracking-wide"){a.letterSpacing="0.025em";continue}if(d==="tracking-wider"){a.letterSpacing="0.05em";continue}if(d==="tracking-widest"){a.letterSpacing="0.1em";continue}const re=d.match(/^tracking-\[(.+)\]$/);if(re){a.letterSpacing=re[1];continue}const sn=d.match(/^w-\[(.+)\]$/);if(sn){a.width=sn[1];continue}const Wt=d.match(/^h-\[(.+)\]$/);if(Wt){a.height=Wt[1];continue}const ji=d.match(/^min-h-\[(.+)\]$/);if(ji){a.minHeight=ji[1];continue}const gn=d.match(/^max-w-\[(.+)\]$/);if(gn){a.maxWidth=gn[1];continue}}return u&&f&&(p?a.backgroundImage=`linear-gradient(${u}, ${f}, ${p}, ${g||f})`:g?a.backgroundImage=`linear-gradient(${u}, ${f}, ${g})`:a.backgroundImage=`linear-gradient(${u}, ${f}, transparent)`),a}function Yn(e,t){const n=parseInt(e.slice(1,3),16),s=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${n}, ${s}, ${i}, ${t})`}const zu={margin:0,padding:0,boxSizing:"border-box",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};function fS(e){return`
|
|
24
24
|
#${e} {
|
|
25
25
|
isolation: isolate;
|
|
26
26
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
@@ -85,11 +85,11 @@ ${c.join(`
|
|
|
85
85
|
font-weight: inherit;
|
|
86
86
|
margin: 0;
|
|
87
87
|
}
|
|
88
|
-
`}function uS(e,t,n,s){return m.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"100%",backgroundColor:e.colors.background,gap:"16px"}},E("p",{style:{color:e.colors.text,fontSize:"1.125rem"}},"Scene not found"),m.createElement("div",{style:{display:"flex",gap:"12px",alignItems:"center"}},t>0&&m.createElement("button",{onClick:n,style:{padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.surfaceHover,color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:e.effects.transition},onMouseOver:i=>i.target.style.backgroundColor=e.colors.border,onMouseOut:i=>i.target.style.backgroundColor=e.colors.surfaceHover},"← Go Back"),s&&m.createElement("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"6px",padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.primary,variant:"outline",color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:"opacity 0.2s"},onMouseOver:i=>i.target.style.opacity="0.85",onMouseOut:i=>i.target.style.opacity="1"},m.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},E("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})),"Generate Scene")))}function dS(e){return m.createElement("div",{key:"preview-modal",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},m.createElement("div",{style:{backgroundColor:e.colors.background,borderRadius:"12px",padding:"24px",maxWidth:"360px",width:"90%",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.08)"}},E("h3",{style:{color:e.colors.text,fontSize:"16px",fontWeight:600,marginBottom:"12px"}},"Sample Modal"),E("p",{style:{color:e.colors.textSecondary,fontSize:"14px",marginBottom:"20px"}},"This is a preview of the modal component for styling."),m.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"}},E("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:"rgba(255,255,255,0.08)",color:e.colors.text,border:`1px solid ${e.colors.borderSubtle}`}},"Cancel"),E("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:e.colors.primary,color:e.colors.text,border:"none"}},"Confirm"))))}function Fu(e,t,n,s,i,r,o){var I,L,O,H,U,q,X,V,D,j,J;if(!e)return null;const{definition:l,closing:c}=e,h=l.variant?(I=l.variants)==null?void 0:I[l.variant]:void 0,a={...l,...h,style:{...l.style,...h==null?void 0:h.style},components:(h==null?void 0:h.components)||l.components,actions:(h==null?void 0:h.actions)||l.actions},u=a.popover===!0,f=(L=a.style)==null?void 0:L.placement,p=f==="left"||f==="right"||f==="bottom"?f:"center",g=a.drawer===!0||p==="left"||p==="right",d=p==="bottom",w=c===!0,C=a.className||"",x=C?((O=n.parseClassNameResponsive)==null?void 0:O.call(n,C,`modal-${e.id}`))??n.parseClassName(C):{},k=u&&o&&o.top>window.innerHeight/2&&o.bottom+300>window.innerHeight,S=o?Math.min(Math.max(12,o.left),Math.max(12,window.innerWidth-372)):void 0,T=()=>{var nt;w||(nt=i||n.dismissModal)==null||nt()},P=m.createElement("div",{key:`modal-overlay-${e.id||"base"}`,style:{position:"fixed",top:0,left:0,right:0,bottom:0,animation:w?"bf-fade-out 0.2s ease forwards":"bf-fade-in 0.15s ease",backdropFilter:u?void 0:"blur(4px)",WebkitBackdropFilter:u?void 0:"blur(4px)",display:"flex",alignItems:u?"flex-start":d?"flex-end":"center",justifyContent:u?"flex-end":g?p==="left"?"flex-start":"flex-end":"center",paddingTop:void 0,paddingRight:void 0,backgroundColor:u?"transparent":((H=a.style)==null?void 0:H.overlayColor)||"rgba(0,0,0,0.45)",pointerEvents:"auto",zIndex:r||1e4},onClick:nt=>{nt.target===nt.currentTarget&&T()}},m.createElement("div",{className:C||void 0,style:{pointerEvents:u?"auto":void 0,...u?{position:"fixed",top:k||!o?k?void 0:"116px":`${o.bottom+8}px`,bottom:k?`${Math.max(12,window.innerHeight-o.top+8)}px`:void 0,left:S===void 0?void 0:`${S}px`,right:S===void 0?"24px":void 0}:{},backgroundColor:((U=a.style)==null?void 0:U.backgroundColor)||s||t.colors.background,borderRadius:g?"0px":((q=a.style)==null?void 0:q.borderRadius)||(d?"16px 16px 0 0":"12px"),padding:g?"0.5rem":d?"16px":"24px",height:g?"100%":"auto",maxHeight:d?"90vh":g?void 0:"85vh",maxWidth:g?"520px":d?n.isMobileView?"none":"640px":((X=a.style)==null?void 0:X.width)||{sm:"min(360px, 92vw)",md:"min(480px, 92vw)",lg:"min(720px, 92vw)",full:"90vw"}[a.size||"sm"]||"min(400px, 92vw)",width:(V=a.style)!=null&&V.width?"100%":g?"90vw":d?"100%":"90%",boxShadow:g?p==="left"?"4px 0 24px rgba(0, 0, 0, 0.4)":"-4px 0 24px rgba(0, 0, 0, 0.4)":d?"0 -8px 32px rgba(0, 0, 0, 0.45)":"0 20px 40px rgba(0, 0, 0, 0.4)",...u?{minWidth:"min(360px, 92vw)",marginRight:"0px",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.45)"}:{},border:"none",borderLeft:g&&p==="right"?`1px solid ${((D=a.style)==null?void 0:D.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",borderRight:g&&p==="left"?`1px solid ${((j=a.style)==null?void 0:j.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",overflow:"auto",animation:g?w?p==="left"?"bf-slide-out-left 0.2s ease forwards":"bf-slide-out-right 0.2s ease forwards":p==="left"?"bf-slide-in-left 0.2s ease":"bf-slide-in-right 0.2s ease":d?w?"bf-slide-out-down 0.2s ease forwards":"bf-slide-in-up 0.25s ease":w?"bf-fade-out 0.2s ease forwards":void 0,...x}},d?m.createElement("div",{key:"bf-sheet-handle",style:{width:"40px",height:"4px",borderRadius:"2px",backgroundColor:"rgba(255, 255, 255, 0.2)",margin:"0 auto 12px",flexShrink:0}}):null,a.icon?m.createElement("div",{style:{textAlign:"center",marginBottom:"12px",display:"flex",justifyContent:"center"}},n.renderIcon(a.icon,32)):null,a.title?m.createElement("h3",{style:{color:t.colors.text,fontSize:a.icon?"18px":"16px",fontWeight:600,marginBottom:"12px",marginTop:"4px",paddingLeft:g?"1.5rem":"0px",paddingRight:g?"1.5rem":"0px",textAlign:a.icon?"center":"left"}},n.interpolateText(a.title)):null,...(a.components||[]).map((nt,it)=>Cr(n,nt,it,"modal")),(((J=a.actions)==null?void 0:J.length)||0)>0?m.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"20px"}},...(a.actions||[]).map((nt,it)=>{const ut=(Dt=>{const qt=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(Dt);if(!qt)return!1;const[ne,te,mt]=[parseInt(qt[1],16),parseInt(qt[2],16),parseInt(qt[3],16)];return(ne*299+te*587+mt*114)/1e3>150})(t.colors.primary)?"#000000":"#ffffff",Ct={primary:{background:t.colors.primary,color:ut,border:"none"},secondary:{background:"rgba(255, 255, 255, 0.08)",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},ghost:{background:"transparent",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},danger:{background:t.colors.danger,color:"#ffffff",border:"none"}},ft=Ct[nt.variant||"primary"]||Ct.primary;return m.createElement("button",{key:it,onClick:()=>{if(e.legacyOnConfirm&&nt.label==="Confirm"){T(),setTimeout(()=>{var Dt;return(Dt=e.legacyOnConfirm)==null?void 0:Dt.call(e)},250);return}nt.onClick&&n.handleButtonClick(nt.onClick,{onSuccess:nt.onSuccess,onError:nt.onError}),nt.dismiss&&T()},style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,...ft}},nt.label)})):null));return u&&typeof document<"u"?Wu.createPortal(P,document.body):P}const ym=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},gr=(...e)=>{ym()&&console.log(...e)},Yo=(...e)=>{ym()&&console.warn(...e)};let bm=null;window.addEventListener("message",e=>{var t,n,s;(((t=e.data)==null?void 0:t.type)==="auth"||((n=e.data)==null?void 0:n.type)==="auth-token")&&((s=e.data)!=null&&s.token)&&(bm=e.data.token,localStorage.setItem("token",e.data.token),e.data.refreshToken&&localStorage.setItem("backflow_refresh_token",e.data.refreshToken),e.data.userId&&localStorage.setItem("backflow_refresh_user_id",e.data.userId))});function ci(e){try{const t=JSON.parse(atob(e.split(".")[1]));return typeof t.exp!="number"||t.exp*1e3<=Date.now()}catch{return!0}}function fS({workflow:e,sdk:t,iconResolver:n,authToken:s,nativeAction:i,onRouteExecute:r,onJobProgress:o,appName:l,appIcon:c,selectedComponentKey:h,selectedComponentClass:a,styleOverrides:u,interactionDisabled:f,theme:p,imageReplacements:g,currentSceneId:d,onSceneChange:w,onGenerateScene:C,enableRouting:x,previewElement:k,tenantId:S,appId:T,renderPhaserGame:P,renderMode:I,apiUrl:L,workflowBaseUrl:O,initialScene:H,previewMode:U,remoteSessionId:q,devDiagnostics:X}){var Xl,Ql,Jl,Kl,Zl,tc,ec,nc,sc,ic,rc,oc,ac;const V=(()=>{const y=bm||localStorage.getItem("token");return!!y&&!ci(y)})(),[D,j]=m.useState(!V),[J,nt]=m.useState(null),it=m.useMemo(()=>Array.isArray(e==null?void 0:e.steps)?e.steps:[],[e]),Q=m.useMemo(()=>{const y=it;return e&&!Array.isArray(e.steps)&&(Yo("[WorkflowRenderer] NON-ARRAY steps:",typeof e.steps,JSON.stringify(e.steps).slice(0,500)),Yo("[WorkflowRenderer] Workflow keys:",Object.keys(e))),D!==!0?y:y.filter(v=>{var b,_;return!(v.requiresAuth===!0||((b=v.config)==null?void 0:b.requireAuth)===!0||((_=v.config)==null?void 0:_.requiresAuth)===!0)})},[e,D,it]),ut=m.useCallback(y=>{var b;const v=it.find(_=>_.id===y);return((b=v==null?void 0:v.config)==null?void 0:b.requireAuth)===!0||(v==null?void 0:v.requiresAuth)===!0},[it]),Ct=e&&!((Xl=e.config)!=null&&Xl.colorMode)?dp(e):void 0,ft=Qu(Ct?{...(e==null?void 0:e.config)||{},colorMode:Ct}:e==null?void 0:e.config,void 0,p),Dt=y=>Al(y,{primary:Et.colors.primary,accent:Et.colors.accent,colorMode:Et.colorMode},Et.colorMode==="light"),qt=I||"legacy",ne=x?"hash":"memory",te=ne!=="memory",[mt,he]=m.useState(V),[Pe,ae]=m.useState(!1),[Nn,Ys]=m.useState(!1),{sceneToRoute:Oe,routeToScene:xe}=m.useMemo(()=>pm(Q),[Q]),bt=m.useMemo(()=>{var v,b;if(H&&Q.some(_=>_.id===H))return H;const y=Q.filter(_=>_.type==="render_scene");return((v=y.find(_=>_.route==="/"))==null?void 0:v.id)||((b=y[0])==null?void 0:b.id)||""},[Q,H]),Rt=m.useMemo(()=>{if(te&&ne==="hash"){const y=Ta(xe);if(y)return y}return bt},[bt,te,ne,xe]),[Lt,kt]=m.useState([]),[yt,wt]=m.useState(Rt),gt=m.useRef(null),Xt=Lf(gt),Ue=m.useRef(!1);m.useRef(null);const ge=m.useRef(!1),ee=m.useRef(!1),rs=m.useRef(0),ue=m.useRef(null);m.useEffect(()=>(ge.current=!1,Xu(),()=>{ge.current=!0}),[]),m.useEffect(()=>{s&&localStorage.setItem("token",s)},[s]);const ot=d??yt;m.useEffect(()=>{var $;const y=Q.find(N=>N.id===ot),v=!!(($=e==null?void 0:e.config)!=null&&$.remoteControl)&&!!(y!=null&&y.remoteScene);if(Vu(v),!v||!q){Jo();return}const b=L||(t==null?void 0:t.endpoint),_=b&&/^https?:\/\//.test(b)?b:window.location.origin,M=new URL("/ws",_);M.protocol=M.protocol==="https:"?"wss:":"ws:";const A=M.toString(),R=`agent:${S||"default"}:${q}`;return Yu(A,R,s||localStorage.getItem("token")||void 0),()=>Jo()},[(Ql=e==null?void 0:e.config)==null?void 0:Ql.remoteControl,Q,ot,q,S,L,t,s]);const Me=m.useCallback(y=>{wt(y),w==null||w(y)},[w]);m.useEffect(()=>{var b;const y=Q.find(_=>_.id===ot),v=((b=y==null?void 0:y.config)==null?void 0:b.requireAuth)===!0||(y==null?void 0:y.requiresAuth)===!0;ot&&!v&&ae(!1)},[ot,Q]);const Gt=(e==null?void 0:e.modals)||{};m.useEffect(()=>{if(!mt)return;const y=Et.startupModal;!y||!Gt[y]||localStorage.getItem(`backflow_startup_modal_${y}`)||se({id:y,definition:Gt[y]})},[mt]);const Xs=m.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("customer_session_token"));m.useEffect(()=>{if(!mt||!Xs.current||!Gt["payment-success"])return;window.history.replaceState({},"",window.location.pathname);const v=setTimeout(()=>{Gt["payment-success"]&&se({id:"payment-success",definition:Gt["payment-success"]})},400);return()=>clearTimeout(v)},[mt,Gt["payment-success"]]),m.useEffect(()=>{D===!0&&(!ot||Q.some(y=>y.id===ot)||bt&&Me(bt))},[D,Q,ot,bt]),m.useEffect(()=>{if(!(!te||ne!=="hash")){if(Ue.current){Ue.current=!1;return}kr(ot,Oe,!1)}},[ot,te,ne,Oe]),m.useEffect(()=>{!te||ne!=="hash"||kr(ot,Oe,!0)},[]);const os=m.useRef(!0);m.useEffect(()=>{const y=setTimeout(()=>{os.current=!1},1500);return()=>clearTimeout(y)},[]),m.useEffect(()=>{if(!te||ne!=="hash")return;const y=v=>{var _;if(os.current)return;const b=((_=v.state)==null?void 0:_.sceneId)||Ta(xe);b&&b!==ot&&(Ue.current=!0,Me(b),kt(M=>M.length>0&&M[M.length-1]===b?M.slice(0,-1):M))};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[te,ne,xe,ot,Me]),m.useEffect(()=>{var v;const y=((v=Q.find(b=>b.type==="render_scene"))==null?void 0:v.id)||"";y&&y!==ot&&(wt(y),kt([]),w==null||w(y),te&&ne==="hash"&&kr(y,Oe,!0))},[e]),m.useEffect(()=>{d&&d!==yt&&wt(d)},[d]);const In=m.useCallback(()=>{if(te){window.history.back();return}if(Lt.length>0){const y=Lt[Lt.length-1];kt(v=>v.slice(0,-1)),Me(y)}},[Lt,te]),[Pt,St]=m.useState({}),Dn=m.useRef(Pt);m.useEffect(()=>{Dn.current=Pt},[Pt]);const[Ln,Ze]=m.useState({}),as=m.useRef(new Set),[Qs,ls]=m.useState({}),[tn,cs]=m.useState({}),[hs,us]=m.useState({}),[Js,Ks]=m.useState({}),[Ee,zn]=m.useState({}),Be=m.useRef(new Map),dn=m.useRef(new Map),Fn=m.useRef(new Set),[Zs,ds]=m.useState(!1),[zt,se]=m.useState(null),[ti,fs]=m.useState(null),ms=m.useRef(null);m.useEffect(()=>{var v;if(!((v=zt==null?void 0:zt.definition)!=null&&v.popover))return;const y=()=>{const b=ms.current;b&&fs(b.getBoundingClientRect())};return window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),y(),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[zt==null?void 0:zt.id,(Jl=zt==null?void 0:zt.definition)==null?void 0:Jl.popover]);const Bn=m.useCallback(()=>{se(y=>y?{...y,closing:!0}:null),setTimeout(()=>se(null),250)},[]),[_e,Wn]=m.useState(null),Wi=m.useCallback(()=>{Wn(y=>y?{...y,closing:!0}:null),setTimeout(()=>Wn(null),250)},[]),ps=Xt>0&&Xt<_i.md;m.useEffect(()=>{e&&typeof e=="object"&&(e.auth={signedIn:mt})},[e,mt]),m.useEffect(()=>{const y=e;if(!(y!=null&&y.config))return;if(c){y.config.logo=c,St(b=>b&&{...b});return}if(!O)return;let v=!1;return(async()=>{for(const b of["svg","png","jpg","jpeg"]){const _=`${O}logo.${b}`;try{if((await fetch(_,{method:"HEAD"})).ok&&!v){y.config.logo=_,St(A=>A&&{...A});return}}catch{}}})(),()=>{v=!0}},[e,O,c]);const[We,fn]=m.useState("login"),[Ot,en]=m.useState(""),[Ft,He]=m.useState(""),[nn,gs]=m.useState(""),[ys,bs]=m.useState({}),[mn,pn]=m.useState(""),[Ie,ie]=m.useState(null),[re,sn]=m.useState(!1),[Wt,Vi]=m.useState({}),gn=y=>y?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y)?null:"Invalid email address":null,tt=y=>y?y.length>=6?null:"Password must be at least 6 characters":null,Yt=(y,v)=>v?v===y?null:"Passwords do not match":null,It=(y,v)=>Vi(b=>({...b,[y]:v||""})),le=y=>{var v,b;return y?typeof y=="string"?y:Array.isArray(y)?((v=y[0])==null?void 0:v.message)||"Validation failed":typeof y.error=="string"?y.error:(b=y.error)!=null&&b.message?y.error.message:y.message||"An error occurred":"An error occurred"},ji=(Pt==null?void 0:Pt._colorMode)||ft.colorMode,vm=ji==="dark"?ki:Mi,Et=ji!==ft.colorMode?{...ft,colorMode:ji,colors:{...vm,...ft.colors&&ji==="dark"?ft.colors:{}}}:ft;m.useEffect(()=>{typeof document>"u"||document.documentElement.setAttribute("data-theme",Et.colorMode==="dark"?"dark":"light")},[Et.colorMode]);const Rl=m.useCallback(y=>{try{localStorage.setItem("bf_theme",y)}catch{}St(v=>({...v,_colorMode:y}))},[]);m.useEffect(()=>{if(typeof localStorage>"u")return;const y=localStorage.getItem("bf_theme");(y==="dark"||y==="light")&&St(v=>({...v,_colorMode:y}))},[]),m.useEffect(()=>{const y=localStorage.getItem("token"),v=!!y&&!ci(y);v?(ee.current=!1,j(!1)):j(!0),he(v);const b=()=>{const A=localStorage.getItem("token"),R=!!A&&!ci(A);R?(ee.current=!1,j(!1)):j(!0),he(R)};window.addEventListener("storage",b);const _=A=>{var R,$,N;if((((R=A.data)==null?void 0:R.type)==="auth"||(($=A.data)==null?void 0:$.type)==="auth-token")&&((N=A.data)!=null&&N.token)){if(localStorage.setItem("token",A.data.token),A.data.refreshToken&&localStorage.setItem("backflow_refresh_token",A.data.refreshToken),A.data.userId&&localStorage.setItem("backflow_refresh_user_id",A.data.userId),ci(A.data.token)){ee.current=!0,he(!1);return}if(!mt&&(Pe||ee.current||!!ue.current)){window.location.reload();return}he(!0),ae(!1),j(!1),ee.current=!1}};window.addEventListener("message",_);const M=()=>{var A;if(!ee.current){const R=Q.find(N=>N.id===ot);if(!(((A=R==null?void 0:R.config)==null?void 0:A.requireAuth)===!0||(R==null?void 0:R.requiresAuth)===!0))return;ee.current=!0,he(!1),ae(!0)}};return window.addEventListener("auth:required",M),()=>{window.removeEventListener("storage",b),window.removeEventListener("message",_),window.removeEventListener("auth:required",M)}},[]);const xm=async()=>{var b;const y=localStorage.getItem("backflow_refresh_token"),v=localStorage.getItem("backflow_refresh_user_id");if(!y||!v)return!1;try{const M=await(await fetch(`${window.location.origin}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:y,userId:v})})).json();if(M.success&&((b=M.data)!=null&&b.token))return M.data.refreshToken&&localStorage.setItem("backflow_refresh_token",M.data.refreshToken),localStorage.setItem("token",M.data.token),!0}catch{}return localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),!1},to=async y=>{var v;if(y.status===401&&!Pe){if(await xm())return!1;gr("[bf] 401 intercepted, showAuth:",Pe,"authInterceptedRef:",ee.current);const _=localStorage.getItem("token"),M=!!_&&!ci(_);if(!ee.current&&!M){ee.current=!0,he(!1);const A=Q.find($=>$.id===ot);(((v=A==null?void 0:A.config)==null?void 0:v.requireAuth)===!0||(A==null?void 0:A.requiresAuth)===!0)&&(ae(!0),ot&&(ue.current=ot))}else M&&gr("[bf] 401 with valid stored token — ignoring");return!0}return!1},wm=ot&&Q.some(y=>y.id===ot)?ot:(Kl=Q[0])==null?void 0:Kl.id,qe=Q.find(y=>y.id===wm),Vt=(qe==null?void 0:qe.type)==="render_scene"?qe.config:null;m.useEffect(()=>{if(!Vt)return;const y=S||"default",v={TENANT_ID:y,tenantId:y,role:"user"};St(b=>{const _={};for(const M of Object.keys(b))M.startsWith("_")&&(_[M]=b[M]);return{...v,...Vt.sceneData||{},..._}})},[ot,Vt]),m.useEffect(()=>{const y=Et.persistedKeys;if(!y||y.length===0)return;const v={};for(const b of y){const _=localStorage.getItem(`bf_persist_${b}`);_&&(v[b]=_)}Object.keys(v).length>0&&St(b=>({...b,...v}))},[ot]),m.useEffect(()=>{const y=Et.persistedKeys;if(!(!y||y.length===0))for(const v of y){const b=Pt[v];b&&localStorage.setItem(`bf_persist_${v}`,String(b))}});const Pl=y=>{const v=y.match(/^(GET|POST|PATCH|DELETE|PUT)\s+(.+)/);return{method:v?v[1]:"POST",path:v?v[2]:y}},_l=y=>{const v={...y};return delete v.TENANT_ID,delete v.tenantId,delete v.role,v},Vn=m.useCallback(async y=>{var _,M,A;if(!y.action)return;const v=String(y.action),b=Dn.current;try{if(v.startsWith("execute_workflow:")){if(!mt)return;const{method:R,path:$}=Pl(v.replace("execute_workflow:","")),N=$.replace(/:(\w+)/g,(et,B)=>{const Z=b[B];return Z===void 0?et:String(Z)}).replace(/\{\{(\w+)\}\}/g,(et,B)=>{const Z=b[B];return Z===void 0?et:String(Z)}),F=Ge(),Y=R!=="GET"&&R!=="DELETE";R!=="GET"&&Nl(R,N,b,!0);const G=await fetch(new URL(N,F).toString(),{method:R,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},...Y?{body:JSON.stringify(_l(b))}:{}});if(ge.current||await to(G)||ge.current)return;if(!G.ok)throw rn(N),new Error(`Route failed: ${G.statusText}`);const W=await G.json();if(ge.current)return;if(W&&typeof W=="object"&&!Array.isArray(W)&&St(et=>({...et,feedback:W})),((_=y.onSuccess)==null?void 0:_.type)==="toast"&&y.onSuccess.value)jt(y.onSuccess.value,"success");else if(((M=y.onSuccess)==null?void 0:M.type)==="navigate"&&y.onSuccess.value){const et=y.onSuccess.value;if(ut(et)&&!mt){ue.current=et,ae(!0);return}kt(Z=>[...Z,ot]),Me(et)}W!=null&&W.data&&St(et=>({...et,...W.data})),W!=null&&W.user&&typeof W.user=="object"&&St(et=>({...et,user:W.user})),ce.current[N.replace(/^\//,"")]={response:W},St(et=>({...et}))}else if(v.startsWith("navigate:")){const R=v.replace("navigate:","");if(ut(R)&&!mt){ue.current=R,ae(!0);return}kt(N=>[...N,ot]),Me(R)}else if(v.startsWith("go_to_step:")){const R=v.replace("go_to_step:","").split("?")[0].trim();if(ut(R)&&!mt){ue.current=R,ae(!0);return}kt(N=>[...N,ot]),Me(R)}else if(v.startsWith("show_toast:")){const R=v.replace("show_toast:","");R&&jt(R,"success")}else if(v.startsWith("show_modal:")){const R=v.replace("show_modal:","");if(Gt[R]){const $=Gt[R],N=$.clearFormKeys;St(F=>{const Y={...F};let G=Array.isArray(N)&&N.length>0;if(G)for(const W of N)delete Y[W];for(const W of Object.keys(Y))W.startsWith("__acc_")&&(delete Y[W],G=!0);return G?Y:F}),$.preload&&await ni(String($.preload)),se({id:R,definition:$})}else{const $=R.split("|");se({id:"__legacy",definition:{title:$[0]||"Notice",components:$[1]?[{type:"text",text:$[1],color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}}else if(v.startsWith("toast:")){const R=v.replace("toast:","");jt(R,"success")}}catch(R){if(R instanceof xs&&io(R,y==null?void 0:y.onError))return;(A=y.onError)!=null&&A.message&&jt(y.onError.message,"error")}},[ot,Q,mt]),eo=m.useRef(null);m.useEffect(()=>{const y=Vt==null?void 0:Vt.events,v=Array.isArray(y==null?void 0:y.onLoad)?y.onLoad:y!=null&&y.onLoad?[y.onLoad]:[];v.length!==0&&(eo.current!==null||ot)&&v.forEach(b=>Vn(b))},[ot,Vt==null?void 0:Vt.events,Vn]),m.useEffect(()=>{var v,b;const y=eo.current;if(eo.current=ot,y&&y!==ot){const _=Q.find(A=>A.id===y),M=(_==null?void 0:_.type)==="render_scene"?_.config:null;(b=(v=M==null?void 0:M.events)==null?void 0:v.onLeave)!=null&&b.action&&Vn(M.events.onLeave)}},[ot,Q,Vn]),m.useEffect(()=>{const y=Vt==null?void 0:Vt.events;if(!(y!=null&&y.onVisibilityChange))return;const v=()=>{var b,_,M,A;document.hidden?(_=(b=y.onVisibilityChange)==null?void 0:b.onHidden)!=null&&_.action&&Vn(y.onVisibilityChange.onHidden):(A=(M=y.onVisibilityChange)==null?void 0:M.onVisible)!=null&&A.action&&Vn(y.onVisibilityChange.onVisible)};return document.addEventListener("visibilitychange",v),()=>document.removeEventListener("visibilitychange",v)},[ot,Vt==null?void 0:Vt.events,Vn]);const Sm=m.useCallback(async(y,v)=>{us(b=>({...b,[y]:!0}));try{await v()}finally{us(b=>({...b,[y]:!1}))}},[]),vs=m.useRef({}),yn=m.useRef(null),no=m.useRef([]),ei=m.useRef({}),Te=m.useCallback(async(y,v,b=0,_=10,M,A,R,$=!1)=>{var F;if(!y||ee.current||!mt)return;vs.current[v]=y;const N=y.match(/^\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*\}\}$/);if(N){const Y=bn(`${N[1]}${N[2]?"."+N[2]:""}`);if(Array.isArray(Y))return Ze(G=>({...G,[v]:Y})),ce.current[v]=Y,ce.current[y]=Y,zn(G=>({...G,[v]:{page:b,limit:_,total:Y.length,hasMore:(b+1)*_<Y.length}})),Y}as.current.has(v)||cs(Y=>({...Y,[v]:!0}));try{let Y=[],G=0,W;const et=Dn.current;if(Ci(y)&&t){const B=Em(y,{limit:_,page:b}),Z=M?Mm(B,M,A):B,dt=pi(Z),z=await Mr(t,dt,et);W=z,Y=(z==null?void 0:z.emails)||(z==null?void 0:z.items)||(z==null?void 0:z.data)||(z==null?void 0:z.history)||(Array.isArray(z)?z:[]),G=((F=z==null?void 0:z.pagination)==null?void 0:F.total)??(z==null?void 0:z.count)??Y.length}else if(!Ci(y)){const B=t==null?void 0:t.endpoint,Z=L||(B&&/^https?:\/\//.test(B)?B:window.location.origin);let dt=y;!L&&B&&!/^https?:\/\//.test(B)&&typeof B=="string"&&(dt=`${B.replace(/\/+$/,"")}${y.startsWith("/")?y:`/${y}`}`),gr("[fetchListData] apiUrl=%s baseUrl=%s dataSource=%s origin=%s",L,Z,y,window.location.origin);const z=new URL(dt,Z);z.searchParams.set("limit",String(_)),z.searchParams.set("offset",String(b*_)),M&&(z.searchParams.set("sort",M),z.searchParams.set("dir",A||"asc"));const at=await fetch(z.toString(),{headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`}});if(await to(at)||ge.current)return;let rt=null;try{rt=await at.json()}catch{}if(!at.ok){const At=typeof(rt==null?void 0:rt.message)=="string"&&rt.message||typeof(rt==null?void 0:rt.error)=="string"&&rt.error||`Request failed: ${at.statusText}`;throw new xs([At],rt||void 0)}if(W=rt,ge.current)return;Y=Array.isArray(rt)?rt:Array.isArray(rt.data)?rt.data:Array.isArray(rt.items)?rt.items:[],G=rt.count??rt.total??Y.length}if(Ze(B=>{if($&&Array.isArray(B[v])){const Z=new Set(B[v].map(z=>z==null?void 0:z.id)),dt=[...B[v],...Y.filter(z=>!Z.has(z==null?void 0:z.id))];return{...B,[v]:dt}}return{...B,[v]:Y}}),as.current.add(v),ce.current[v]=Y,y&&(ce.current[y]=Y),R&&(ce.current[R]={items:Y,response:W},y)){const B=ei.current[R];B&&B!==y&&Yo(`[renderer] duplicate list key "${R}" used for both ${B} and ${y}`),ei.current[R]=y}{const B=String(y||"").replace(/^\//,"").split("?")[0];B&&(ce.current[B]={response:W})}return zn(B=>({...B,[v]:{page:b,limit:_,total:G,hasMore:(b+1)*_<G}})),Y}catch(Y){if(Y instanceof xs&&io(Y))return;Ze(G=>{const W=G[v];return Array.isArray(W)&&W.length>0?G:{...G,[v]:[]}})}finally{cs(Y=>({...Y,[v]:!1}))}},[t,mt]),Ge=()=>{const y=L||(t==null?void 0:t.endpoint);return y&&/^https?:\/\//.test(y)?y:y!=null&&y.startsWith("/")?`${window.location.origin}${y}`:window.location.origin};m.useEffect(()=>{var M;if(!mt)return;const y=s||localStorage.getItem("token");if(!y){j(!0);return}const v=((e==null?void 0:e.steps)||[]).find(A=>A.id===ot);if(!(((M=v==null?void 0:v.config)==null?void 0:M.requireAuth)===!0||(v==null?void 0:v.requiresAuth)===!0||Pe))return;let _=!1;return(async()=>{var A;try{const R=await fetch(`${Ge()}/admin/users/me`,{headers:{Authorization:`Bearer ${y}`}});if(_)return;if(R.ok){const $=await R.json().catch(()=>null);j(!1),nt(typeof((A=$==null?void 0:$.user)==null?void 0:A.emailVerified)=="boolean"?$.user.emailVerified:null)}else ot&&(ue.current=ot),j(!0),he(!1),nt(null)}catch{_||(ot&&(ue.current=ot),j(!0))}})(),()=>{_=!0}},[mt,ot,e==null?void 0:e.steps]);const $l=m.useCallback((y,v,b)=>{!y||v.length===0||Ze(_=>{const M={..._};for(const[A,R]of Object.entries(vs.current)){if(R!==y||!_[A])continue;const $=_[A];b==="remove"&&(M[A]=$.filter(N=>!v.includes(N.id)))}return M})},[]),rn=m.useCallback((y,v)=>{var M,A;const b=new Map;for(const[R,$]of Object.entries(ei.current))b.set($,R);const _=new Map;for(const[R,$]of Object.entries(vs.current))_.set(R,{ds:$,dataKey:b.get($)});for(const[R,$]of Object.entries(ei.current))Object.values(vs.current).includes($)||_.set(R,{ds:$,dataKey:R});if(_.size!==0)for(const[R,{ds:$,dataKey:N}]of _){if(v==="view"){Te($,R,0,((M=Ee[R])==null?void 0:M.limit)||10,void 0,void 0,N);continue}$&&y.startsWith($)&&Te($,R,0,((A=Ee[R])==null?void 0:A.limit)||10,void 0,void 0,N)}},[Te,Ee]),Nl=m.useCallback((y,v,b,_)=>{const M=String(y||"").toUpperCase();if(M==="GET"||_===!1)return;const A=_==="remove"||_==="merge"||_==="add"||_==="refresh"?_:M==="DELETE"?"remove":M==="PUT"||M==="PATCH"?"merge":M==="POST"?"add":null;if(!A||A==="refresh")return;const R=()=>{const N=String(v).match(/\/([^/]+)\/?$/);return N?decodeURIComponent(N[1]):void 0},$=[];for(const[N,F]of Object.entries(vs.current))F&&v.startsWith(F)&&$.push({key:N,ds:F});$.length!==0&&Ze(N=>{const F={...N};for(const{key:Y,ds:G}of $){const W=N[Y]||[];if(A==="remove"){const et=(b==null?void 0:b.id)||R();F[Y]=W.filter(B=>B.id!==et)}else if(A==="merge"){const et=(b==null?void 0:b.id)||R();F[Y]=W.map(B=>B.id===et?{...B,...b}:B)}else{const et={...b||{},id:(b==null?void 0:b.id)||`temp_${Date.now()}`};A==="add"&&et.status===void 0&&(et.status="queued"),F[Y]=[et,...W]}}return F})},[]),Oi=m.useCallback((y,v,b,_)=>{var N;const M=Ge();let A=!1;const R=F=>{A||(A=!0,F())},$=t==null?void 0:t.queues;if(y==="sse"&&($!=null&&$.subscribe))try{const F=_.sseUrl||`${M}/queues/bulk-operations/jobs/${v}/subscribe?token=${encodeURIComponent(b)}`,Y=((t==null?void 0:t.endpoint)||M).replace(/\/$/,""),G=F.startsWith(Y)?F.slice(Y.length):F;$.subscribe(G,{onComplete:W=>R(()=>_.onComplete(W)),onFailed:W=>R(()=>_.onFailed({message:W||"Subscription failed",kind:"transport"})),onError:()=>R(()=>_.onFailed({message:"Stream error",kind:"transport"})),onConnected:()=>{},onProgress:W=>{var et;return(et=_.onProgress)==null?void 0:et.call(_,W)}}),setTimeout(()=>R(()=>_.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(y==="ws"&&((N=t==null?void 0:t.client)!=null&&N.createWebSocket))try{const F=t.client.createWebSocket(`job:${v}`);F.onmessage=Y=>{try{const G=JSON.parse(Y.data);(G==null?void 0:G.type)==="completed"?R(()=>_.onComplete(G.result)):(G==null?void 0:G.type)==="failed"&&R(()=>_.onFailed({message:G.error||"Job failed",kind:"job"}))}catch{}},F.onerror=()=>R(()=>_.onFailed({message:"Connection error",kind:"transport"})),setTimeout(()=>R(()=>_.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(y==="poll"&&($!=null&&$.getJob)){const F=window.setInterval(async()=>{var Y;try{const G=await $.getJob("bulk-operations",v),W=(G==null?void 0:G.status)||((Y=G==null?void 0:G.job)==null?void 0:Y.status),et=(G==null?void 0:G.result)||(G==null?void 0:G.data);W==="failed"||et!=null&&et.final?(window.clearInterval(F),R(()=>W==="failed"?_.onFailed({message:(et==null?void 0:et.error)||"Job failed",kind:"job"}):_.onComplete(et))):W==="completed"&&(window.clearInterval(F),R(()=>_.onComplete(et)))}catch{}},600);setTimeout(()=>{window.clearInterval(F),R(()=>_.onFailed({message:"Timed out",kind:"transport"}))},3e4);return}R(()=>_.onFailed({message:"Feedback transport unavailable",kind:"transport"}))},[]),Cm=m.useCallback(async(y,v,b)=>{var Y,G;const _=t==null?void 0:t.files,M=encodeURIComponent(s||localStorage.getItem("token")||"");if(_!=null&&_.upload){const W=await _.upload(y,v||{},b),et=(W==null?void 0:W.url)||(W==null?void 0:W.path)||"";return et?(W==null?void 0:W.visibility)==="public"?et:`${Ge()}${et}?token=${M}`:""}const A=new FormData;A.append("file",y),v!=null&&v.entityType&&A.append("entityType",v.entityType),v!=null&&v.entityId&&A.append("entityId",v.entityId),v!=null&&v.visibility&&A.append("visibility",v.visibility);const R=await fetch(`${Ge()}/files/upload`,{method:"POST",headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:A});if(!R.ok)throw new Error("Upload failed");const $=await R.json(),N=((Y=$==null?void 0:$.asset)==null?void 0:Y.url)||($==null?void 0:$.url)||($==null?void 0:$.path)||($==null?void 0:$.id)||"";return N?((G=$==null?void 0:$.asset)==null?void 0:G.visibility)==="public"?N:`${Ge()}${N}?token=${M}`:""},[]),km=m.useCallback(async(y,v,b,_)=>{var R;if(!(y!=null&&y.endpoint)||_.length===0)return;const M=y.endpoint,A=y.optimistic??!0;try{const $=await fetch(Ge()+M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:JSON.stringify({ids:_})});let N={};try{N=await $.json()}catch{}if(!$.ok){jt(((R=N==null?void 0:N.error)==null?void 0:R.message)||"Request failed","error");return}A!==!1&&(A==="remove"||A==="refresh"?A:N.softUpdate||(y.action==="delete"?"remove":"refresh"))==="remove"&&$l(v,_,"remove"),St(Y=>({...Y,_selIds:[],_selectMode:!1}));const F=(Y,G,W)=>{var et;if(Y)jt(W||"Bulk operation failed","error");else{const B=G||{},Z=B.total??_.length,dt=B.successful??Z;jt(dt>=Z?`${dt} ${y.action}d`:`${dt} of ${Z} ${y.action}d`,"success")}Te(v,b,0,((et=Ee[b])==null?void 0:et.limit)||10)};N.jobId&&N.token&&y.feedback?Oi(y.feedback,N.jobId,N.token,{onComplete:Y=>F(!1,Y),onFailed:Y=>{var G;if(Y.kind==="transport"){Te(v,b,0,((G=Ee[b])==null?void 0:G.limit)||10);return}F(!0,null,Y.message)}}):F(!1,N)}catch{jt("Request failed","error")}},[$l,Oi,Te,Ee]),Mm=(y,v,b)=>{const _=pi(y),M=_.indexOf("(");if(M===-1)return y;const A=_.slice(M+1,-1).trim(),R=`sort: "${v}", dir: ${b==="desc"?'"desc"':'"asc"'}`;if(!A)return y.replace(/\(\)$/,`({${R}})`);const $=A.lastIndexOf(",");if($===-1)return y.replace(/\(([^)]*)\)$/,`(${A}, {${R}})`);const N=A.slice($+1).trim();return N.startsWith("{")?y.replace(/\(([^)]*)\)$/,`(${A.slice(0,$)}, {${N.slice(1,-1)}, ${R}})`):y.replace(/\(([^)]*)\)$/,`(${A}, {${R}})`)},Em=(y,v)=>{const b=pi(y),_=b.indexOf("(");if(_===-1)return y;const M=b.slice(_+1,-1).trim(),A=`limit: ${v.limit}, page: ${v.page}`;if(!M)return y.replace(/\(\)$/,`({${A}})`);const R=M.lastIndexOf(",");if(R===-1)return y.replace(/\(([^)]*)\)$/,`(${M}, {${A}})`);const $=M.slice(R+1).trim();return $.startsWith("{")?y.replace(/\(([^)]*)\)$/,`(${M.slice(0,R)}, {${$.slice(1,-1)}, ${A}})`):y.replace(/\(([^)]*)\)$/,`(${M}, {${A}})`)};m.useEffect(()=>()=>{ge.current=!0},[]),Et.colors.background;const we=m.useMemo(()=>`bf-preview-${Math.random().toString(36).slice(2,9)}`,[]),Tm=y=>y.replace(/:(\w+)/g,(v,b)=>{const _=Pt[b];return _===void 0?v:String(_)}),Am=y=>{try{const v=JSON.parse(y);if(Array.isArray(v)&&v.length>0)return v.map(b=>{var _;return b.message||`${((_=b.path)==null?void 0:_.join("."))||"field"} is invalid`})}catch{}return null};class xs extends Error{constructor(b,_){super(b.join(", "));go(this,"errors");go(this,"body");this.errors=b,this.body=_}}const ni=async(y,v)=>{var et,B,Z,dt;if(ee.current||!mt)return;const{method:b,path:_}=Pl(y),M=Tm(_),A=b!=="GET"&&b!=="DELETE",R=Ge();b!=="GET"&&Nl(b,M,Pt,(v==null?void 0:v.optimistic)??!0);let $;if(v!=null&&v.payload&&typeof v.payload=="object"){$={};for(const[z,at]of Object.entries(v.payload))$[z]=typeof at=="string"&&at.includes("{{")?ao(at):at}else $=Pt;$=_l($);const N=await fetch(new URL(M,R).toString(),{method:b,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},...A?{body:JSON.stringify($)}:{}});if(await to(N)||ge.current)return;let F;try{F=await N.json()}catch{if(ge.current)return;if(!N.ok)throw new xs([`Request failed: ${N.statusText}`]);return}if(!N.ok||F.success===!1){rn(M,v==null?void 0:v.refetchScope);let z=["Something went wrong"];throw(et=F.error)!=null&&et.message?z=Am(F.error.message)||[F.error.message]:F.message&&(z=[F.message]),new xs(z,F)}F.token&&localStorage.setItem("token",F.token),F&&typeof F=="object"&&!Array.isArray(F)&&St(z=>({...z,feedback:F})),F.data&&(v==null?void 0:v.mergeResponse)!==!1&&St(z=>({...z,...F.data})),F.user&&typeof F.user=="object"?St(z=>({...z,user:F.user})):St(z=>({...z})),ce.current[M.replace(/^\//,"")]={response:F};for(const[z,at]of Object.entries(ei.current))if(at===M||at.endsWith(M)){const rt=ce.current[z];ce.current[z]={items:Array.isArray(rt)?rt:Array.isArray(rt==null?void 0:rt.items)?rt.items:[],response:F}}const Y=(Z=(B=F.subscribe)==null?void 0:B.websocket)==null?void 0:Z.workflowChannel;Y&&(v==null?void 0:v.mergeResponse)!==!1&&St(z=>{var at,rt,At,$t;return{...z,liveCastChannel:Y,execution_id:F.draftId||z.execution_id,id:F.sessionId||z.id,status:"running",test_session:{...z.test_session||{},id:F.sessionId||((at=z.test_session)==null?void 0:at.id),execution_id:F.draftId||((rt=z.test_session)==null?void 0:rt.execution_id),status:"running",liveCastChannel:Y,prompt:($==null?void 0:$.prompt)||((At=z.test_session)==null?void 0:At.prompt),url:($==null?void 0:$.url)||(($t=z.test_session)==null?void 0:$t.url)}}}),rn(M,(v==null?void 0:v.refetchScope)||(b!=="GET"?"view":void 0));const G=v==null?void 0:v.feedback,W=typeof G=="string"?G:G==null?void 0:G.transport;if(W&&F.jobId&&(F.token||(dt=F.subscribe)!=null&&dt.sse||typeof G=="object")){let z;if(typeof G=="object"&&G.subscribeUrl){const at=String(G.subscribeUrl).trim(),rt=at.startsWith("{{")&&at.endsWith("}}")?at.slice(2,-2).trim():at,At=rt.match(/^\[(.+?)\](?:\.(.*))?$/),$t=At?bn(`${At[1]}${At[2]?"."+At[2]:""}`):rt.split(".").reduce((Se,de)=>Se==null?void 0:Se[de],F);$t&&(z=/^https?:\/\//.test($t)?$t:R+$t)}if(z){Oi(W,F.jobId,F.token,{sseUrl:z,onProgress:at=>{o==null||o(at);const rt=Date.now();rt-rs.current>=2e3&&(rs.current=rt,rn(M,v==null?void 0:v.refetchScope))},onComplete:at=>{const rt=(at==null?void 0:at.result)??at;if(rt&&typeof rt=="object"){const At=M.replace(/^\//,"");ce.current[At]={response:rt},St($t=>({...$t}))}rn(M,v==null?void 0:v.refetchScope)},onFailed:at=>{rn(M,v==null?void 0:v.refetchScope),at.kind!=="transport"&&jt(at.message||"Job failed","error")}});return}Oi(W,F.jobId,F.token,{onComplete:at=>{const rt=at||{},At=rt.total,$t=rt.successful;At!==void 0&&jt($t>=At?`${$t} completed`:`${$t} of ${At} completed`,"success"),rn(M,v==null?void 0:v.refetchScope)},onFailed:at=>{if(at.kind==="transport"){rn(M,v==null?void 0:v.refetchScope);return}jt(at.message||"Job failed","error"),rn(M,v==null?void 0:v.refetchScope)}})}},on=y=>{var _,M;se(null);const v=y==="/"&&(((_=Q.find(A=>A.route==="/"))==null?void 0:_.id)||((M=Q.find(A=>A.type==="render_scene"))==null?void 0:M.id))||y;if(ut(v)&&!mt){ue.current=v,ae(!0);return}kt(A=>[...A,ot]),Me(v)},so=(y,v="error")=>{if(St(b=>({...b,gateTitle:y.uiTitle||"Usage Notice",gateMessage:y.message})),y.uiVariant!=="modal"){const b=y.uiTitle?`${y.uiTitle}
|
|
89
|
-
${y.message}`:y.message;
|
|
88
|
+
`}function mS(e,t,n,s){return m.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"100%",backgroundColor:e.colors.background,gap:"16px"}},E("p",{style:{color:e.colors.text,fontSize:"1.125rem"}},"Scene not found"),m.createElement("div",{style:{display:"flex",gap:"12px",alignItems:"center"}},t>0&&m.createElement("button",{onClick:n,style:{padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.surfaceHover,color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:e.effects.transition},onMouseOver:i=>i.target.style.backgroundColor=e.colors.border,onMouseOut:i=>i.target.style.backgroundColor=e.colors.surfaceHover},"← Go Back"),s&&m.createElement("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"6px",padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.primary,variant:"outline",color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:"opacity 0.2s"},onMouseOver:i=>i.target.style.opacity="0.85",onMouseOut:i=>i.target.style.opacity="1"},m.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},E("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})),"Generate Scene")))}function pS(e){return m.createElement("div",{key:"preview-modal",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},m.createElement("div",{style:{backgroundColor:e.colors.background,borderRadius:"12px",padding:"24px",maxWidth:"360px",width:"90%",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.08)"}},E("h3",{style:{color:e.colors.text,fontSize:"16px",fontWeight:600,marginBottom:"12px"}},"Sample Modal"),E("p",{style:{color:e.colors.textSecondary,fontSize:"14px",marginBottom:"20px"}},"This is a preview of the modal component for styling."),m.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"}},E("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:"rgba(255,255,255,0.08)",color:e.colors.text,border:`1px solid ${e.colors.borderSubtle}`}},"Cancel"),E("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:e.colors.primary,color:e.colors.text,border:"none"}},"Confirm"))))}function Fu(e,t,n,s,i,r,o){var I,L,O,H,U,q,X,j,D,V,J;if(!e)return null;const{definition:l,closing:c}=e,h=l.variant?(I=l.variants)==null?void 0:I[l.variant]:void 0,a={...l,...h,style:{...l.style,...h==null?void 0:h.style},components:(h==null?void 0:h.components)||l.components,actions:(h==null?void 0:h.actions)||l.actions},u=a.popover===!0,f=(L=a.style)==null?void 0:L.placement,p=f==="left"||f==="right"||f==="bottom"?f:"center",g=a.drawer===!0||p==="left"||p==="right",d=p==="bottom",w=c===!0,C=a.className||"",x=C?((O=n.parseClassNameResponsive)==null?void 0:O.call(n,C,`modal-${e.id}`))??n.parseClassName(C):{},k=u&&o&&o.top>window.innerHeight/2&&o.bottom+300>window.innerHeight,S=o?Math.min(Math.max(12,o.left),Math.max(12,window.innerWidth-372)):void 0,T=()=>{var nt;w||(nt=i||n.dismissModal)==null||nt()},P=m.createElement("div",{key:`modal-overlay-${e.id||"base"}`,style:{position:"fixed",top:0,left:0,right:0,bottom:0,animation:w?"bf-fade-out 0.2s ease forwards":"bf-fade-in 0.15s ease",backdropFilter:u?void 0:"blur(4px)",WebkitBackdropFilter:u?void 0:"blur(4px)",display:"flex",alignItems:u?"flex-start":d?"flex-end":"center",justifyContent:u?"flex-end":g?p==="left"?"flex-start":"flex-end":"center",paddingTop:void 0,paddingRight:void 0,backgroundColor:u?"transparent":((H=a.style)==null?void 0:H.overlayColor)||"rgba(0,0,0,0.45)",pointerEvents:"auto",zIndex:r||1e4},onClick:nt=>{nt.target===nt.currentTarget&&T()}},m.createElement("div",{className:C||void 0,style:{pointerEvents:u?"auto":void 0,...u?{position:"fixed",top:k||!o?k?void 0:"116px":`${o.bottom+8}px`,bottom:k?`${Math.max(12,window.innerHeight-o.top+8)}px`:void 0,left:S===void 0?void 0:`${S}px`,right:S===void 0?"24px":void 0}:{},backgroundColor:((U=a.style)==null?void 0:U.backgroundColor)||s||t.colors.background,borderRadius:g?"0px":((q=a.style)==null?void 0:q.borderRadius)||(d?"16px 16px 0 0":"12px"),padding:g?"0.5rem":d?"16px":"24px",height:g?"100%":"auto",maxHeight:d?"90vh":g?void 0:"85vh",maxWidth:g?"520px":d?n.isMobileView?"none":"640px":((X=a.style)==null?void 0:X.width)||{sm:"min(360px, 92vw)",md:"min(480px, 92vw)",lg:"min(720px, 92vw)",full:"90vw"}[a.size||"sm"]||"min(400px, 92vw)",width:(j=a.style)!=null&&j.width?"100%":g?"90vw":d?"100%":"90%",boxShadow:g?p==="left"?"4px 0 24px rgba(0, 0, 0, 0.4)":"-4px 0 24px rgba(0, 0, 0, 0.4)":d?"0 -8px 32px rgba(0, 0, 0, 0.45)":"0 20px 40px rgba(0, 0, 0, 0.4)",...u?{minWidth:"min(360px, 92vw)",marginRight:"0px",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.45)"}:{},border:"none",borderLeft:g&&p==="right"?`1px solid ${((D=a.style)==null?void 0:D.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",borderRight:g&&p==="left"?`1px solid ${((V=a.style)==null?void 0:V.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",overflow:"auto",animation:g?w?p==="left"?"bf-slide-out-left 0.2s ease forwards":"bf-slide-out-right 0.2s ease forwards":p==="left"?"bf-slide-in-left 0.2s ease":"bf-slide-in-right 0.2s ease":d?w?"bf-slide-out-down 0.2s ease forwards":"bf-slide-in-up 0.25s ease":w?"bf-fade-out 0.2s ease forwards":void 0,...x}},d?m.createElement("div",{key:"bf-sheet-handle",style:{width:"40px",height:"4px",borderRadius:"2px",backgroundColor:"rgba(255, 255, 255, 0.2)",margin:"0 auto 12px",flexShrink:0}}):null,a.icon?m.createElement("div",{style:{textAlign:"center",marginBottom:"12px",display:"flex",justifyContent:"center"}},n.renderIcon(a.icon,32)):null,a.title?m.createElement("h3",{style:{color:t.colors.text,fontSize:a.icon?"18px":"16px",fontWeight:600,marginBottom:"12px",marginTop:"4px",paddingLeft:g?"1.5rem":"0px",paddingRight:g?"1.5rem":"0px",textAlign:a.icon?"center":"left"}},n.interpolateText(a.title)):null,...(a.components||[]).map((nt,it)=>Cr(n,nt,it,"modal")),(((J=a.actions)==null?void 0:J.length)||0)>0?m.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"20px"}},...(a.actions||[]).map((nt,it)=>{const ut=(Dt=>{const qt=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(Dt);if(!qt)return!1;const[ne,te,mt]=[parseInt(qt[1],16),parseInt(qt[2],16),parseInt(qt[3],16)];return(ne*299+te*587+mt*114)/1e3>150})(t.colors.primary)?"#000000":"#ffffff",Ct={primary:{background:t.colors.primary,color:ut,border:"none"},secondary:{background:"rgba(255, 255, 255, 0.08)",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},ghost:{background:"transparent",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},danger:{background:t.colors.danger,color:"#ffffff",border:"none"}},ft=Ct[nt.variant||"primary"]||Ct.primary;return m.createElement("button",{key:it,onClick:()=>{if(e.legacyOnConfirm&&nt.label==="Confirm"){T(),setTimeout(()=>{var Dt;return(Dt=e.legacyOnConfirm)==null?void 0:Dt.call(e)},250);return}nt.onClick&&n.handleButtonClick(nt.onClick,{onSuccess:nt.onSuccess,onError:nt.onError}),nt.dismiss&&T()},style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,...ft}},nt.label)})):null));return u&&typeof document<"u"?Wu.createPortal(P,document.body):P}const bm=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},gr=(...e)=>{bm()&&console.log(...e)},Yo=(...e)=>{bm()&&console.warn(...e)};let vm=null;window.addEventListener("message",e=>{var t,n,s;(((t=e.data)==null?void 0:t.type)==="auth"||((n=e.data)==null?void 0:n.type)==="auth-token")&&((s=e.data)!=null&&s.token)&&(vm=e.data.token,localStorage.setItem("token",e.data.token),e.data.refreshToken&&localStorage.setItem("backflow_refresh_token",e.data.refreshToken),e.data.userId&&localStorage.setItem("backflow_refresh_user_id",e.data.userId))});function ci(e){try{const t=JSON.parse(atob(e.split(".")[1]));return typeof t.exp!="number"||t.exp*1e3<=Date.now()}catch{return!0}}function gS({workflow:e,sdk:t,iconResolver:n,authToken:s,nativeAction:i,onRouteExecute:r,onJobProgress:o,appName:l,appIcon:c,selectedComponentKey:h,selectedComponentClass:a,styleOverrides:u,interactionDisabled:f,theme:p,imageReplacements:g,currentSceneId:d,onSceneChange:w,onGenerateScene:C,enableRouting:x,previewElement:k,tenantId:S,appId:T,renderPhaserGame:P,renderMode:I,apiUrl:L,workflowBaseUrl:O,initialScene:H,previewMode:U,remoteSessionId:q,devDiagnostics:X}){var Yl,Xl,Ql,Jl,Kl,Zl,tc,ec,nc,sc,ic,rc,oc;const j=(()=>{const y=vm||localStorage.getItem("token");return!!y&&!ci(y)})(),[D,V]=m.useState(!j),[J,nt]=m.useState(null),it=m.useMemo(()=>Array.isArray(e==null?void 0:e.steps)?e.steps:[],[e]),Q=m.useMemo(()=>{const y=it;return e&&!Array.isArray(e.steps)&&(Yo("[WorkflowRenderer] NON-ARRAY steps:",typeof e.steps,JSON.stringify(e.steps).slice(0,500)),Yo("[WorkflowRenderer] Workflow keys:",Object.keys(e))),D!==!0?y:y.filter(v=>{var b,_;return!(v.requiresAuth===!0||((b=v.config)==null?void 0:b.requireAuth)===!0||((_=v.config)==null?void 0:_.requiresAuth)===!0)})},[e,D,it]),ut=m.useCallback(y=>{var b;const v=it.find(_=>_.id===y);return((b=v==null?void 0:v.config)==null?void 0:b.requireAuth)===!0||(v==null?void 0:v.requiresAuth)===!0},[it]),Ct=e&&!((Yl=e.config)!=null&&Yl.colorMode)?pp(e):void 0,ft=Ju(Ct?{...(e==null?void 0:e.config)||{},colorMode:Ct}:e==null?void 0:e.config,void 0,p),Dt=y=>Tl(y,{primary:Et.colors.primary,accent:Et.colors.accent,colorMode:Et.colorMode},Et.colorMode==="light"),qt=I||"legacy",ne=x?"hash":"memory",te=ne!=="memory",[mt,he]=m.useState(j),[Pe,ae]=m.useState(!1),[In,Ys]=m.useState(!1),{sceneToRoute:Oe,routeToScene:xe}=m.useMemo(()=>gm(Q),[Q]),bt=m.useMemo(()=>{var v,b;if(H&&Q.some(_=>_.id===H))return H;const y=Q.filter(_=>_.type==="render_scene");return((v=y.find(_=>_.route==="/"))==null?void 0:v.id)||((b=y[0])==null?void 0:b.id)||""},[Q,H]),Rt=m.useMemo(()=>{if(te&&ne==="hash"){const y=Ta(xe);if(y)return y}return bt},[bt,te,ne,xe]),[Lt,kt]=m.useState([]),[yt,wt]=m.useState(Rt),gt=m.useRef(null),Xt=zf(gt),Ue=m.useRef(!1);m.useRef(null);const ge=m.useRef(!1),ee=m.useRef(!1),os=m.useRef(0),ue=m.useRef(null);m.useEffect(()=>(ge.current=!1,Qu(),()=>{ge.current=!0}),[]),m.useEffect(()=>{s&&localStorage.setItem("token",s)},[s]);const ot=d??yt;m.useEffect(()=>{var $;const y=Q.find(N=>N.id===ot),v=!!(($=e==null?void 0:e.config)!=null&&$.remoteControl)&&!!(y!=null&&y.remoteScene);if(ju(v),!v||!q){Jo();return}const b=L||(t==null?void 0:t.endpoint),_=b&&/^https?:\/\//.test(b)?b:window.location.origin,M=new URL("/ws",_);M.protocol=M.protocol==="https:"?"wss:":"ws:";const A=M.toString(),R=`agent:${S||"default"}:${q}`;return Xu(A,R,s||localStorage.getItem("token")||void 0),()=>Jo()},[(Xl=e==null?void 0:e.config)==null?void 0:Xl.remoteControl,Q,ot,q,S,L,t,s]);const Me=m.useCallback(y=>{wt(y),w==null||w(y)},[w]);m.useEffect(()=>{var b;const y=Q.find(_=>_.id===ot),v=((b=y==null?void 0:y.config)==null?void 0:b.requireAuth)===!0||(y==null?void 0:y.requiresAuth)===!0;ot&&!v&&ae(!1)},[ot,Q]);const Gt=(e==null?void 0:e.modals)||{};m.useEffect(()=>{if(!mt)return;const y=Et.startupModal;!y||!Gt[y]||localStorage.getItem(`backflow_startup_modal_${y}`)||se({id:y,definition:Gt[y]})},[mt]);const Xs=m.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("customer_session_token"));m.useEffect(()=>{if(!mt||!Xs.current||!Gt["payment-success"])return;window.history.replaceState({},"",window.location.pathname);const v=setTimeout(()=>{Gt["payment-success"]&&se({id:"payment-success",definition:Gt["payment-success"]})},400);return()=>clearTimeout(v)},[mt,Gt["payment-success"]]),m.useEffect(()=>{D===!0&&(!ot||Q.some(y=>y.id===ot)||bt&&Me(bt))},[D,Q,ot,bt]),m.useEffect(()=>{if(!(!te||ne!=="hash")){if(Ue.current){Ue.current=!1;return}kr(ot,Oe,!1)}},[ot,te,ne,Oe]),m.useEffect(()=>{!te||ne!=="hash"||kr(ot,Oe,!0)},[]);const as=m.useRef(!0);m.useEffect(()=>{const y=setTimeout(()=>{as.current=!1},1500);return()=>clearTimeout(y)},[]),m.useEffect(()=>{if(!te||ne!=="hash")return;const y=v=>{var _;if(as.current)return;const b=((_=v.state)==null?void 0:_.sceneId)||Ta(xe);b&&b!==ot&&(Ue.current=!0,Me(b),kt(M=>M.length>0&&M[M.length-1]===b?M.slice(0,-1):M))};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[te,ne,xe,ot,Me]),m.useEffect(()=>{var v;const y=((v=Q.find(b=>b.type==="render_scene"))==null?void 0:v.id)||"";y&&y!==ot&&(wt(y),kt([]),w==null||w(y),te&&ne==="hash"&&kr(y,Oe,!0))},[e]),m.useEffect(()=>{d&&d!==yt&&wt(d)},[d]);const Dn=m.useCallback(()=>{if(te){window.history.back();return}if(Lt.length>0){const y=Lt[Lt.length-1];kt(v=>v.slice(0,-1)),Me(y)}},[Lt,te]),[Pt,St]=m.useState({}),Ln=m.useRef(Pt);m.useEffect(()=>{Ln.current=Pt},[Pt]);const[zn,Ze]=m.useState({}),ls=m.useRef(new Set),[Qs,cs]=m.useState({}),[tn,hs]=m.useState({}),[us,ds]=m.useState({}),[Js,Ks]=m.useState({}),[Ee,Fn]=m.useState({}),Be=m.useRef(new Map),dn=m.useRef(new Map),Bn=m.useRef(new Set),[Zs,fs]=m.useState(!1),[zt,se]=m.useState(null),[ti,ms]=m.useState(null),ps=m.useRef(null);m.useEffect(()=>{var v;if(!((v=zt==null?void 0:zt.definition)!=null&&v.popover))return;const y=()=>{const b=ps.current;b&&ms(b.getBoundingClientRect())};return window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),y(),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[zt==null?void 0:zt.id,(Ql=zt==null?void 0:zt.definition)==null?void 0:Ql.popover]);const Wn=m.useCallback(()=>{se(y=>y?{...y,closing:!0}:null),setTimeout(()=>se(null),250)},[]),[_e,jn]=m.useState(null),Wi=m.useCallback(()=>{jn(y=>y?{...y,closing:!0}:null),setTimeout(()=>jn(null),250)},[]),gs=Xt>0&&Xt<_i.md;m.useEffect(()=>{e&&typeof e=="object"&&(e.auth={signedIn:mt})},[e,mt]),m.useEffect(()=>{const y=e;if(!(y!=null&&y.config))return;if(c){y.config.logo=c,St(b=>b&&{...b});return}if(!O)return;let v=!1;return(async()=>{for(const b of["svg","png","jpg","jpeg"]){const _=`${O}logo.${b}`;try{if((await fetch(_,{method:"HEAD"})).ok&&!v){y.config.logo=_,St(A=>A&&{...A});return}}catch{}}})(),()=>{v=!0}},[e,O,c]);const[We,fn]=m.useState("login"),[Ot,en]=m.useState(""),[Ft,He]=m.useState(""),[nn,ys]=m.useState(""),[bs,vs]=m.useState({}),[mn,pn]=m.useState(""),[Ie,ie]=m.useState(null),[re,sn]=m.useState(!1),[Wt,ji]=m.useState({}),gn=y=>y?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y)?null:"Invalid email address":null,tt=y=>y?y.length>=6?null:"Password must be at least 6 characters":null,Yt=(y,v)=>v?v===y?null:"Passwords do not match":null,It=(y,v)=>ji(b=>({...b,[y]:v||""})),le=y=>{var v,b;return y?typeof y=="string"?y:Array.isArray(y)?((v=y[0])==null?void 0:v.message)||"Validation failed":typeof y.error=="string"?y.error:(b=y.error)!=null&&b.message?y.error.message:y.message||"An error occurred":"An error occurred"},Vi=(Pt==null?void 0:Pt._colorMode)||ft.colorMode,xm=Vi==="dark"?ki:Mi,Et=Vi!==ft.colorMode?{...ft,colorMode:Vi,colors:{...xm,...ft.colors&&Vi==="dark"?ft.colors:{}}}:ft;m.useEffect(()=>{typeof document>"u"||document.documentElement.setAttribute("data-theme",Et.colorMode==="dark"?"dark":"light")},[Et.colorMode]);const Al=m.useCallback(y=>{try{localStorage.setItem("bf_theme",y)}catch{}St(v=>({...v,_colorMode:y}))},[]);m.useEffect(()=>{if(typeof localStorage>"u")return;const y=localStorage.getItem("bf_theme");(y==="dark"||y==="light")&&St(v=>({...v,_colorMode:y}))},[]),m.useEffect(()=>{const y=localStorage.getItem("token"),v=!!y&&!ci(y);v?(ee.current=!1,V(!1)):V(!0),he(v);const b=()=>{const A=localStorage.getItem("token"),R=!!A&&!ci(A);R?(ee.current=!1,V(!1)):V(!0),he(R)};window.addEventListener("storage",b);const _=A=>{var R,$,N;if((((R=A.data)==null?void 0:R.type)==="auth"||(($=A.data)==null?void 0:$.type)==="auth-token")&&((N=A.data)!=null&&N.token)){if(localStorage.setItem("token",A.data.token),A.data.refreshToken&&localStorage.setItem("backflow_refresh_token",A.data.refreshToken),A.data.userId&&localStorage.setItem("backflow_refresh_user_id",A.data.userId),ci(A.data.token)){ee.current=!0,he(!1);return}if(!mt&&(Pe||ee.current||!!ue.current)){window.location.reload();return}he(!0),ae(!1),V(!1),ee.current=!1}};window.addEventListener("message",_);const M=()=>{var A;if(!ee.current){const R=Q.find(N=>N.id===ot);if(!(((A=R==null?void 0:R.config)==null?void 0:A.requireAuth)===!0||(R==null?void 0:R.requiresAuth)===!0))return;ee.current=!0,he(!1),ae(!0)}};return window.addEventListener("auth:required",M),()=>{window.removeEventListener("storage",b),window.removeEventListener("message",_),window.removeEventListener("auth:required",M)}},[]);const wm=async()=>{var b;const y=localStorage.getItem("backflow_refresh_token"),v=localStorage.getItem("backflow_refresh_user_id");if(!y||!v)return!1;try{const M=await(await fetch(`${window.location.origin}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:y,userId:v})})).json();if(M.success&&((b=M.data)!=null&&b.token))return M.data.refreshToken&&localStorage.setItem("backflow_refresh_token",M.data.refreshToken),localStorage.setItem("token",M.data.token),!0}catch{}return localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),!1},to=async y=>{var v;if(y.status===401&&!Pe){if(await wm())return!1;gr("[bf] 401 intercepted, showAuth:",Pe,"authInterceptedRef:",ee.current);const _=localStorage.getItem("token"),M=!!_&&!ci(_);if(!ee.current&&!M){ee.current=!0,he(!1);const A=Q.find($=>$.id===ot);(((v=A==null?void 0:A.config)==null?void 0:v.requireAuth)===!0||(A==null?void 0:A.requiresAuth)===!0)&&(ae(!0),ot&&(ue.current=ot))}else M&&gr("[bf] 401 with valid stored token — ignoring");return!0}return!1},Sm=ot&&Q.some(y=>y.id===ot)?ot:(Jl=Q[0])==null?void 0:Jl.id,qe=Q.find(y=>y.id===Sm),jt=(qe==null?void 0:qe.type)==="render_scene"?qe.config:null;m.useEffect(()=>{if(!jt)return;const y=S||"default",v={TENANT_ID:y,tenantId:y,role:"user"};St(b=>{const _={};for(const M of Object.keys(b))M.startsWith("_")&&(_[M]=b[M]);return{...v,...jt.sceneData||{},..._}})},[ot,jt]),m.useEffect(()=>{const y=Et.persistedKeys;if(!y||y.length===0)return;const v={};for(const b of y){const _=localStorage.getItem(`bf_persist_${b}`);_&&(v[b]=_)}Object.keys(v).length>0&&St(b=>({...b,...v}))},[ot]),m.useEffect(()=>{const y=Et.persistedKeys;if(!(!y||y.length===0))for(const v of y){const b=Pt[v];b&&localStorage.setItem(`bf_persist_${v}`,String(b))}});const Rl=y=>{const v=y.match(/^(GET|POST|PATCH|DELETE|PUT)\s+(.+)/);return{method:v?v[1]:"POST",path:v?v[2]:y}},Pl=y=>{const v={...y};return delete v.TENANT_ID,delete v.tenantId,delete v.role,v},Vn=m.useCallback(async y=>{var _,M,A;if(!y.action)return;const v=String(y.action),b=Ln.current;try{if(v.startsWith("execute_workflow:")){if(!mt)return;const{method:R,path:$}=Rl(v.replace("execute_workflow:","")),N=$.replace(/:(\w+)/g,(et,B)=>{const Z=b[B];return Z===void 0?et:String(Z)}).replace(/\{\{(\w+)\}\}/g,(et,B)=>{const Z=b[B];return Z===void 0?et:String(Z)}),F=Ge(),Y=R!=="GET"&&R!=="DELETE";R!=="GET"&&$l(R,N,b,!0);const G=await fetch(new URL(N,F).toString(),{method:R,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},...Y?{body:JSON.stringify(Pl(b))}:{}});if(ge.current||await to(G)||ge.current)return;if(!G.ok)throw rn(N),new Error(`Route failed: ${G.statusText}`);const W=await G.json();if(ge.current)return;if(W&&typeof W=="object"&&!Array.isArray(W)&&St(et=>({...et,feedback:W})),((_=y.onSuccess)==null?void 0:_.type)==="toast"&&y.onSuccess.value)Vt(y.onSuccess.value,"success");else if(((M=y.onSuccess)==null?void 0:M.type)==="navigate"&&y.onSuccess.value){const et=y.onSuccess.value;if(ut(et)&&!mt){ue.current=et,ae(!0);return}kt(Z=>[...Z,ot]),Me(et)}W!=null&&W.data&&St(et=>({...et,...W.data})),W!=null&&W.user&&typeof W.user=="object"&&St(et=>({...et,user:W.user})),ce.current[N.replace(/^\//,"")]={response:W},St(et=>({...et}))}else if(v.startsWith("navigate:")){const R=v.replace("navigate:","");if(ut(R)&&!mt){ue.current=R,ae(!0);return}kt(N=>[...N,ot]),Me(R)}else if(v.startsWith("go_to_step:")){const R=v.replace("go_to_step:","").split("?")[0].trim();if(ut(R)&&!mt){ue.current=R,ae(!0);return}kt(N=>[...N,ot]),Me(R)}else if(v.startsWith("show_toast:")){const R=v.replace("show_toast:","");R&&Vt(R,"success")}else if(v.startsWith("show_modal:")){const R=v.replace("show_modal:","");if(Gt[R]){const $=Gt[R],N=$.clearFormKeys;St(F=>{const Y={...F};let G=Array.isArray(N)&&N.length>0;if(G)for(const W of N)delete Y[W];for(const W of Object.keys(Y))W.startsWith("__acc_")&&(delete Y[W],G=!0);return G?Y:F}),$.preload&&await ni(String($.preload)),se({id:R,definition:$})}else{const $=R.split("|");se({id:"__legacy",definition:{title:$[0]||"Notice",components:$[1]?[{type:"text",text:$[1],color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}}else if(v.startsWith("toast:")){const R=v.replace("toast:","");Vt(R,"success")}}catch(R){if(R instanceof ws&&io(R,y==null?void 0:y.onError))return;(A=y.onError)!=null&&A.message&&Vt(y.onError.message,"error")}},[ot,Q,mt]),eo=m.useRef(null);m.useEffect(()=>{const y=jt==null?void 0:jt.events,v=Array.isArray(y==null?void 0:y.onLoad)?y.onLoad:y!=null&&y.onLoad?[y.onLoad]:[];v.length!==0&&(eo.current!==null||ot)&&v.forEach(b=>Vn(b))},[ot,jt==null?void 0:jt.events,Vn]),m.useEffect(()=>{var v,b;const y=eo.current;if(eo.current=ot,y&&y!==ot){const _=Q.find(A=>A.id===y),M=(_==null?void 0:_.type)==="render_scene"?_.config:null;(b=(v=M==null?void 0:M.events)==null?void 0:v.onLeave)!=null&&b.action&&Vn(M.events.onLeave)}},[ot,Q,Vn]),m.useEffect(()=>{const y=jt==null?void 0:jt.events;if(!(y!=null&&y.onVisibilityChange))return;const v=()=>{var b,_,M,A;document.hidden?(_=(b=y.onVisibilityChange)==null?void 0:b.onHidden)!=null&&_.action&&Vn(y.onVisibilityChange.onHidden):(A=(M=y.onVisibilityChange)==null?void 0:M.onVisible)!=null&&A.action&&Vn(y.onVisibilityChange.onVisible)};return document.addEventListener("visibilitychange",v),()=>document.removeEventListener("visibilitychange",v)},[ot,jt==null?void 0:jt.events,Vn]);const Cm=m.useCallback(async(y,v)=>{ds(b=>({...b,[y]:!0}));try{await v()}finally{ds(b=>({...b,[y]:!1}))}},[]),xs=m.useRef({}),yn=m.useRef(null),no=m.useRef([]),ei=m.useRef({}),Te=m.useCallback(async(y,v,b=0,_=10,M,A,R,$=!1)=>{var F;if(!y||ee.current||!mt)return;xs.current[v]=y;const N=y.match(/^\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*\}\}$/);if(N){const Y=bn(`${N[1]}${N[2]?"."+N[2]:""}`);if(Array.isArray(Y))return Ze(G=>({...G,[v]:Y})),ce.current[v]=Y,ce.current[y]=Y,Fn(G=>({...G,[v]:{page:b,limit:_,total:Y.length,hasMore:(b+1)*_<Y.length}})),Y}ls.current.has(v)||hs(Y=>({...Y,[v]:!0}));try{let Y=[],G=0,W;const et=Ln.current;if(Ci(y)&&t){const B=Tm(y,{limit:_,page:b}),Z=M?Em(B,M,A):B,dt=pi(Z),z=await Mr(t,dt,et);W=z,Y=(z==null?void 0:z.emails)||(z==null?void 0:z.items)||(z==null?void 0:z.data)||(z==null?void 0:z.history)||(Array.isArray(z)?z:[]),G=((F=z==null?void 0:z.pagination)==null?void 0:F.total)??(z==null?void 0:z.count)??Y.length}else if(!Ci(y)){const B=t==null?void 0:t.endpoint,Z=L||(B&&/^https?:\/\//.test(B)?B:window.location.origin);let dt=y;!L&&B&&!/^https?:\/\//.test(B)&&typeof B=="string"&&(dt=`${B.replace(/\/+$/,"")}${y.startsWith("/")?y:`/${y}`}`),gr("[fetchListData] apiUrl=%s baseUrl=%s dataSource=%s origin=%s",L,Z,y,window.location.origin);const z=new URL(dt,Z);z.searchParams.set("limit",String(_)),z.searchParams.set("offset",String(b*_)),M&&(z.searchParams.set("sort",M),z.searchParams.set("dir",A||"asc"));const at=await fetch(z.toString(),{headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`}});if(await to(at)||ge.current)return;let rt=null;try{rt=await at.json()}catch{}if(!at.ok){const At=typeof(rt==null?void 0:rt.message)=="string"&&rt.message||typeof(rt==null?void 0:rt.error)=="string"&&rt.error||`Request failed: ${at.statusText}`;throw new ws([At],rt||void 0)}if(W=rt,ge.current)return;Y=Array.isArray(rt)?rt:Array.isArray(rt.data)?rt.data:Array.isArray(rt.items)?rt.items:[],G=rt.count??rt.total??Y.length}if(Ze(B=>{if($&&Array.isArray(B[v])){const Z=new Set(B[v].map(z=>z==null?void 0:z.id)),dt=[...B[v],...Y.filter(z=>!Z.has(z==null?void 0:z.id))];return{...B,[v]:dt}}return{...B,[v]:Y}}),ls.current.add(v),ce.current[v]=Y,y&&(ce.current[y]=Y),R&&(ce.current[R]={items:Y,response:W},y)){const B=ei.current[R];B&&B!==y&&Yo(`[renderer] duplicate list key "${R}" used for both ${B} and ${y}`),ei.current[R]=y}{const B=String(y||"").replace(/^\//,"").split("?")[0];B&&(ce.current[B]={response:W})}return Fn(B=>({...B,[v]:{page:b,limit:_,total:G,hasMore:(b+1)*_<G}})),Y}catch(Y){if(Y instanceof ws&&io(Y))return;Ze(G=>{const W=G[v];return Array.isArray(W)&&W.length>0?G:{...G,[v]:[]}})}finally{hs(Y=>({...Y,[v]:!1}))}},[t,mt]),Ge=()=>{const y=L||(t==null?void 0:t.endpoint);return y&&/^https?:\/\//.test(y)?y:y!=null&&y.startsWith("/")?`${window.location.origin}${y}`:window.location.origin};m.useEffect(()=>{var M;if(!mt)return;const y=s||localStorage.getItem("token");if(!y){V(!0);return}const v=((e==null?void 0:e.steps)||[]).find(A=>A.id===ot);if(!(((M=v==null?void 0:v.config)==null?void 0:M.requireAuth)===!0||(v==null?void 0:v.requiresAuth)===!0||Pe))return;let _=!1;return(async()=>{var A;try{const R=await fetch(`${Ge()}/admin/users/me`,{headers:{Authorization:`Bearer ${y}`}});if(_)return;if(R.ok){const $=await R.json().catch(()=>null);V(!1),nt(typeof((A=$==null?void 0:$.user)==null?void 0:A.emailVerified)=="boolean"?$.user.emailVerified:null)}else ot&&(ue.current=ot),V(!0),he(!1),nt(null)}catch{_||(ot&&(ue.current=ot),V(!0))}})(),()=>{_=!0}},[mt,ot,e==null?void 0:e.steps]);const _l=m.useCallback((y,v,b)=>{!y||v.length===0||Ze(_=>{const M={..._};for(const[A,R]of Object.entries(xs.current)){if(R!==y||!_[A])continue;const $=_[A];b==="remove"&&(M[A]=$.filter(N=>!v.includes(N.id)))}return M})},[]),rn=m.useCallback((y,v)=>{var M,A;const b=new Map;for(const[R,$]of Object.entries(ei.current))b.set($,R);const _=new Map;for(const[R,$]of Object.entries(xs.current))_.set(R,{ds:$,dataKey:b.get($)});for(const[R,$]of Object.entries(ei.current))Object.values(xs.current).includes($)||_.set(R,{ds:$,dataKey:R});if(_.size!==0)for(const[R,{ds:$,dataKey:N}]of _){if(v==="view"){Te($,R,0,((M=Ee[R])==null?void 0:M.limit)||10,void 0,void 0,N);continue}$&&y.startsWith($)&&Te($,R,0,((A=Ee[R])==null?void 0:A.limit)||10,void 0,void 0,N)}},[Te,Ee]),$l=m.useCallback((y,v,b,_)=>{const M=String(y||"").toUpperCase();if(M==="GET"||_===!1)return;const A=_==="remove"||_==="merge"||_==="add"||_==="refresh"?_:M==="DELETE"?"remove":M==="PUT"||M==="PATCH"?"merge":M==="POST"?"add":null;if(!A||A==="refresh")return;const R=()=>{const N=String(v).match(/\/([^/]+)\/?$/);return N?decodeURIComponent(N[1]):void 0},$=[];for(const[N,F]of Object.entries(xs.current))F&&v.startsWith(F)&&$.push({key:N,ds:F});$.length!==0&&Ze(N=>{const F={...N};for(const{key:Y,ds:G}of $){const W=N[Y]||[];if(A==="remove"){const et=(b==null?void 0:b.id)||R();F[Y]=W.filter(B=>B.id!==et)}else if(A==="merge"){const et=(b==null?void 0:b.id)||R();F[Y]=W.map(B=>B.id===et?{...B,...b}:B)}else{const et={...b||{},id:(b==null?void 0:b.id)||`temp_${Date.now()}`};A==="add"&&et.status===void 0&&(et.status="queued"),F[Y]=[et,...W]}}return F})},[]),Oi=m.useCallback((y,v,b,_)=>{var N;const M=Ge();let A=!1;const R=F=>{A||(A=!0,F())},$=t==null?void 0:t.queues;if(y==="sse"&&($!=null&&$.subscribe))try{const F=_.sseUrl||`${M}/queues/bulk-operations/jobs/${v}/subscribe?token=${encodeURIComponent(b)}`,Y=((t==null?void 0:t.endpoint)||M).replace(/\/$/,""),G=F.startsWith(Y)?F.slice(Y.length):F;$.subscribe(G,{onComplete:W=>R(()=>_.onComplete(W)),onFailed:W=>R(()=>_.onFailed({message:W||"Subscription failed",kind:"transport"})),onError:()=>R(()=>_.onFailed({message:"Stream error",kind:"transport"})),onConnected:()=>{},onProgress:W=>{var et;return(et=_.onProgress)==null?void 0:et.call(_,W)}}),setTimeout(()=>R(()=>_.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(y==="ws"&&((N=t==null?void 0:t.client)!=null&&N.createWebSocket))try{const F=t.client.createWebSocket(`job:${v}`);F.onmessage=Y=>{try{const G=JSON.parse(Y.data);(G==null?void 0:G.type)==="completed"?R(()=>_.onComplete(G.result)):(G==null?void 0:G.type)==="failed"&&R(()=>_.onFailed({message:G.error||"Job failed",kind:"job"}))}catch{}},F.onerror=()=>R(()=>_.onFailed({message:"Connection error",kind:"transport"})),setTimeout(()=>R(()=>_.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(y==="poll"&&($!=null&&$.getJob)){const F=window.setInterval(async()=>{var Y;try{const G=await $.getJob("bulk-operations",v),W=(G==null?void 0:G.status)||((Y=G==null?void 0:G.job)==null?void 0:Y.status),et=(G==null?void 0:G.result)||(G==null?void 0:G.data);W==="failed"||et!=null&&et.final?(window.clearInterval(F),R(()=>W==="failed"?_.onFailed({message:(et==null?void 0:et.error)||"Job failed",kind:"job"}):_.onComplete(et))):W==="completed"&&(window.clearInterval(F),R(()=>_.onComplete(et)))}catch{}},600);setTimeout(()=>{window.clearInterval(F),R(()=>_.onFailed({message:"Timed out",kind:"transport"}))},3e4);return}R(()=>_.onFailed({message:"Feedback transport unavailable",kind:"transport"}))},[]),km=m.useCallback(async(y,v,b)=>{var Y,G;const _=t==null?void 0:t.files,M=encodeURIComponent(s||localStorage.getItem("token")||"");if(_!=null&&_.upload){const W=await _.upload(y,v||{},b),et=(W==null?void 0:W.url)||(W==null?void 0:W.path)||"";return et?(W==null?void 0:W.visibility)==="public"?et:`${Ge()}${et}?token=${M}`:""}const A=new FormData;A.append("file",y),v!=null&&v.entityType&&A.append("entityType",v.entityType),v!=null&&v.entityId&&A.append("entityId",v.entityId),v!=null&&v.visibility&&A.append("visibility",v.visibility);const R=await fetch(`${Ge()}/files/upload`,{method:"POST",headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:A});if(!R.ok)throw new Error("Upload failed");const $=await R.json(),N=((Y=$==null?void 0:$.asset)==null?void 0:Y.url)||($==null?void 0:$.url)||($==null?void 0:$.path)||($==null?void 0:$.id)||"";return N?((G=$==null?void 0:$.asset)==null?void 0:G.visibility)==="public"?N:`${Ge()}${N}?token=${M}`:""},[]),Mm=m.useCallback(async(y,v,b,_)=>{var R;if(!(y!=null&&y.endpoint)||_.length===0)return;const M=y.endpoint,A=y.optimistic??!0;try{const $=await fetch(Ge()+M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:JSON.stringify({ids:_})});let N={};try{N=await $.json()}catch{}if(!$.ok){Vt(((R=N==null?void 0:N.error)==null?void 0:R.message)||"Request failed","error");return}A!==!1&&(A==="remove"||A==="refresh"?A:N.softUpdate||(y.action==="delete"?"remove":"refresh"))==="remove"&&_l(v,_,"remove"),St(Y=>({...Y,_selIds:[],_selectMode:!1}));const F=(Y,G,W)=>{var et;if(Y)Vt(W||"Bulk operation failed","error");else{const B=G||{},Z=B.total??_.length,dt=B.successful??Z;Vt(dt>=Z?`${dt} ${y.action}d`:`${dt} of ${Z} ${y.action}d`,"success")}Te(v,b,0,((et=Ee[b])==null?void 0:et.limit)||10)};N.jobId&&N.token&&y.feedback?Oi(y.feedback,N.jobId,N.token,{onComplete:Y=>F(!1,Y),onFailed:Y=>{var G;if(Y.kind==="transport"){Te(v,b,0,((G=Ee[b])==null?void 0:G.limit)||10);return}F(!0,null,Y.message)}}):F(!1,N)}catch{Vt("Request failed","error")}},[_l,Oi,Te,Ee]),Em=(y,v,b)=>{const _=pi(y),M=_.indexOf("(");if(M===-1)return y;const A=_.slice(M+1,-1).trim(),R=`sort: "${v}", dir: ${b==="desc"?'"desc"':'"asc"'}`;if(!A)return y.replace(/\(\)$/,`({${R}})`);const $=A.lastIndexOf(",");if($===-1)return y.replace(/\(([^)]*)\)$/,`(${A}, {${R}})`);const N=A.slice($+1).trim();return N.startsWith("{")?y.replace(/\(([^)]*)\)$/,`(${A.slice(0,$)}, {${N.slice(1,-1)}, ${R}})`):y.replace(/\(([^)]*)\)$/,`(${A}, {${R}})`)},Tm=(y,v)=>{const b=pi(y),_=b.indexOf("(");if(_===-1)return y;const M=b.slice(_+1,-1).trim(),A=`limit: ${v.limit}, page: ${v.page}`;if(!M)return y.replace(/\(\)$/,`({${A}})`);const R=M.lastIndexOf(",");if(R===-1)return y.replace(/\(([^)]*)\)$/,`(${M}, {${A}})`);const $=M.slice(R+1).trim();return $.startsWith("{")?y.replace(/\(([^)]*)\)$/,`(${M.slice(0,R)}, {${$.slice(1,-1)}, ${A}})`):y.replace(/\(([^)]*)\)$/,`(${M}, {${A}})`)};m.useEffect(()=>()=>{ge.current=!0},[]),Et.colors.background;const we=m.useMemo(()=>`bf-preview-${Math.random().toString(36).slice(2,9)}`,[]),Am=y=>y.replace(/:(\w+)/g,(v,b)=>{const _=Pt[b];return _===void 0?v:String(_)}),Rm=y=>{try{const v=JSON.parse(y);if(Array.isArray(v)&&v.length>0)return v.map(b=>{var _;return b.message||`${((_=b.path)==null?void 0:_.join("."))||"field"} is invalid`})}catch{}return null};class ws extends Error{constructor(b,_){super(b.join(", "));go(this,"errors");go(this,"body");this.errors=b,this.body=_}}const ni=async(y,v)=>{var et,B,Z,dt;if(ee.current||!mt)return;const{method:b,path:_}=Rl(y),M=Am(_),A=b!=="GET"&&b!=="DELETE",R=Ge();b!=="GET"&&$l(b,M,Pt,(v==null?void 0:v.optimistic)??!0);let $;if(v!=null&&v.payload&&typeof v.payload=="object"){$={};for(const[z,at]of Object.entries(v.payload))$[z]=typeof at=="string"&&at.includes("{{")?ao(at):at}else $=Pt;$=Pl($);const N=await fetch(new URL(M,R).toString(),{method:b,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},...A?{body:JSON.stringify($)}:{}});if(await to(N)||ge.current)return;let F;try{F=await N.json()}catch{if(ge.current)return;if(!N.ok)throw new ws([`Request failed: ${N.statusText}`]);return}if(!N.ok||F.success===!1){rn(M,v==null?void 0:v.refetchScope);let z=["Something went wrong"];throw(et=F.error)!=null&&et.message?z=Rm(F.error.message)||[F.error.message]:F.message&&(z=[F.message]),new ws(z,F)}F.token&&localStorage.setItem("token",F.token),F&&typeof F=="object"&&!Array.isArray(F)&&St(z=>({...z,feedback:F})),F.data&&(v==null?void 0:v.mergeResponse)!==!1&&St(z=>({...z,...F.data})),F.user&&typeof F.user=="object"?St(z=>({...z,user:F.user})):St(z=>({...z})),ce.current[M.replace(/^\//,"")]={response:F};for(const[z,at]of Object.entries(ei.current))if(at===M||at.endsWith(M)){const rt=ce.current[z];ce.current[z]={items:Array.isArray(rt)?rt:Array.isArray(rt==null?void 0:rt.items)?rt.items:[],response:F}}const Y=(Z=(B=F.subscribe)==null?void 0:B.websocket)==null?void 0:Z.workflowChannel;Y&&(v==null?void 0:v.mergeResponse)!==!1&&St(z=>{var at,rt,At,$t;return{...z,liveCastChannel:Y,execution_id:F.draftId||z.execution_id,id:F.sessionId||z.id,status:"running",test_session:{...z.test_session||{},id:F.sessionId||((at=z.test_session)==null?void 0:at.id),execution_id:F.draftId||((rt=z.test_session)==null?void 0:rt.execution_id),status:"running",liveCastChannel:Y,prompt:($==null?void 0:$.prompt)||((At=z.test_session)==null?void 0:At.prompt),url:($==null?void 0:$.url)||(($t=z.test_session)==null?void 0:$t.url)}}}),rn(M,(v==null?void 0:v.refetchScope)||(b!=="GET"?"view":void 0));const G=v==null?void 0:v.feedback,W=typeof G=="string"?G:G==null?void 0:G.transport;if(W&&F.jobId&&(F.token||(dt=F.subscribe)!=null&&dt.sse||typeof G=="object")){let z;if(typeof G=="object"&&G.subscribeUrl){const at=String(G.subscribeUrl).trim(),rt=at.startsWith("{{")&&at.endsWith("}}")?at.slice(2,-2).trim():at,At=rt.match(/^\[(.+?)\](?:\.(.*))?$/),$t=At?bn(`${At[1]}${At[2]?"."+At[2]:""}`):rt.split(".").reduce((Se,de)=>Se==null?void 0:Se[de],F);$t&&(z=/^https?:\/\//.test($t)?$t:R+$t)}if(z){Oi(W,F.jobId,F.token,{sseUrl:z,onProgress:at=>{o==null||o(at);const rt=Date.now();rt-os.current>=2e3&&(os.current=rt,rn(M,v==null?void 0:v.refetchScope))},onComplete:at=>{const rt=(at==null?void 0:at.result)??at;if(rt&&typeof rt=="object"){const At=M.replace(/^\//,"");ce.current[At]={response:rt},St($t=>({...$t}))}rn(M,v==null?void 0:v.refetchScope)},onFailed:at=>{rn(M,v==null?void 0:v.refetchScope),at.kind!=="transport"&&Vt(at.message||"Job failed","error")}});return}Oi(W,F.jobId,F.token,{onComplete:at=>{const rt=at||{},At=rt.total,$t=rt.successful;At!==void 0&&Vt($t>=At?`${$t} completed`:`${$t} of ${At} completed`,"success"),rn(M,v==null?void 0:v.refetchScope)},onFailed:at=>{if(at.kind==="transport"){rn(M,v==null?void 0:v.refetchScope);return}Vt(at.message||"Job failed","error"),rn(M,v==null?void 0:v.refetchScope)}})}},on=y=>{var _,M;se(null);const v=y==="/"&&(((_=Q.find(A=>A.route==="/"))==null?void 0:_.id)||((M=Q.find(A=>A.type==="render_scene"))==null?void 0:M.id))||y;if(ut(v)&&!mt){ue.current=v,ae(!0);return}kt(A=>[...A,ot]),Me(v)},so=(y,v="error")=>{if(St(b=>({...b,gateTitle:y.uiTitle||"Usage Notice",gateMessage:y.message})),y.uiVariant!=="modal"){const b=y.uiTitle?`${y.uiTitle}
|
|
89
|
+
${y.message}`:y.message;Vt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.modalId,definition:Gt[y.modalId]});return}se({id:"__legacy",definition:{title:y.uiTitle||"Usage Notice",components:[{type:"text",text:y.message,color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})},io=(y,v)=>{const b=y.body;if(!b)return!1;const _=typeof(b==null?void 0:b.message)=="string"&&b.message||y.errors[0]||"Request blocked by limits",M=()=>so({message:_,uiVariant:b.uiVariant,uiTitle:typeof(b==null?void 0:b.uiTitle)=="string"?b.uiTitle:void 0,modalId:typeof(b==null?void 0:b.modalId)=="string"?b.modalId:void 0});return b.gateAction==="login"?(fn("login"),!0):b.gateAction==="upgrade"?b.uiVariant==="modal"||typeof(b==null?void 0:b.modalId)=="string"?(M(),!0):v!=null&&v.upgradeScene?(on(v.upgradeScene),!0):(M(),!0):b.gateAction==="block"||b.gateAction==="warn"||b.warning?(M(),!0):!1};m.useEffect(()=>{if(!mt||D)return;const y=ue.current;!y||!Q.some(v=>v.id===y)||(ue.current=null,on(y))},[mt,D,Q]);const Vt=(y,v="success",b)=>{const _=Array.isArray(y)?y.join(`
|
|
90
90
|
`):y,M=v==="success",A=M?"#10B981":"#EF4444",R=Et.toast||{},$=b??R.duration??3e3,N=R.position||"bottom-right",F={"bottom-right":{right:"24px",bottom:"24px"},"bottom-left":{left:"24px",bottom:"24px"},"bottom-center":{left:"50%",bottom:"24px",transform:"translateX(-50%)"},"top-right":{right:"24px",top:"24px"},"top-left":{left:"24px",top:"24px"},"top-center":{left:"50%",top:"24px",transform:"translateX(-50%)"}},Y=F[N]||F["bottom-right"],G=document.createElement("div"),W=document.createElement("span");W.textContent=M?"✓":"✕",Object.assign(W.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"22px",height:"22px",minWidth:"22px",borderRadius:"50%",backgroundColor:`${A}26`,color:A,fontSize:"12px",fontWeight:"700"});const et=document.createElement("span");et.textContent=_,Object.assign(et.style,{color:"rgba(255, 255, 255, 0.92)",fontSize:"13.5px",lineHeight:"1.45",whiteSpace:"pre-line"}),Object.assign(G.style,{position:"fixed",...Y,zIndex:"2147483647",display:"flex",alignItems:"flex-start",gap:"10px",padding:"12px 16px",borderRadius:"12px",backgroundColor:"rgba(23, 25, 35, 0.97)",border:"1px solid rgba(148, 163, 184, 0.25)",boxShadow:"0 8px 28px rgba(0, 0, 0, 0.4)",maxWidth:"380px",opacity:"0",pointerEvents:"auto"}),G.appendChild(W),G.appendChild(et),document.body.appendChild(G),G.animate([{opacity:0,transform:"translateX(24px)"},{opacity:1,transform:"translateX(0)"}],{duration:250,easing:"cubic-bezier(0.16, 1, 0.3, 1)",fill:"both"}).finished.catch(()=>{});const Z=()=>{G.animate([{opacity:1,transform:"translateX(0)"},{opacity:0,transform:"translateX(16px)"}],{duration:200,easing:"ease",fill:"both"}).finished.then(()=>G.remove()).catch(()=>G.remove())};return $>0&&setTimeout(Z,$),{update:dt=>{et.textContent=Array.isArray(dt)?dt.join(`
|
|
91
|
-
`):dt},dismiss:Z}},ws=(y,v=!0)=>{if(v&&(y!=null&&y.onSuccess)){const b=Array.isArray(y.onSuccess)?y.onSuccess:[y.onSuccess];for(const _ of b){const{type:M,value:A,title:R,key:$}=_;switch(M){case"toast":jt(A||"Success!","success");break;case"navigate":A&&on(A);break;case"redirect":A&&(window.location.href=A);break;case"modal":A&&Gt[A]?se({id:A,definition:Gt[A]}):se({id:"__legacy",definition:{title:R||"Success",components:A?[{type:"text",text:A,color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}});break;case"route":A&&ni(A);break;case"set_data":$&&A!==void 0&&St(N=>({...N,[$]:A}));break}}}else!v&&(y!=null&&y.onError)&&jt(y.onError.message||"An error occurred","error")},Rm=()=>{var Se,de,ii,Xi,Qt,_t,Jt;const y=async()=>{var Tt,Ye,On,Un,Ce,lc;if(!Ot||!Ft||We==="register"&&!nn)return;const st=gn(Ot),pt=tt(Ft);if(st||pt){ie(st||pt);return}if(We==="register"&&nn!==Ft){It("confirm","Passwords do not match"),ie("Passwords do not match");return}sn(!0),ie(null);try{const xn=We==="login"?"/auth/login":"/auth/register",Qi=`${Ge().replace(/\/+$/,"")}${xn}`,Xm=We==="login"?{email:Ot,password:Ft,tenantId:S}:{email:Ot,password:Ft,displayName:Ot.split("@")[0],tenantId:S},cc={"Content-Type":"application/json"};T&&(cc["x-app-id"]=T);const po=await fetch(Qi,{method:"POST",headers:cc,body:JSON.stringify(Xm)});if(!po.ok){const Qm=await po.json().catch(()=>({error:"Authentication failed"}));throw new Error(le(Qm))}const Le=await po.json();if(Array.isArray(Le)||Le.success===!1)throw new Error(le(Le));const hc=((Tt=Le.data)==null?void 0:Tt.token)||Le.token||Le.accessToken||Le.idToken;hc&&localStorage.setItem("token",hc);const uc=((Ye=Le.data)==null?void 0:Ye.refreshToken)||Le.refreshToken;uc&&localStorage.setItem("backflow_refresh_token",uc);const dc=((Un=(On=Le.data)==null?void 0:On.user)==null?void 0:Un.id)||((Ce=Le.user)==null?void 0:Ce.id)||((lc=Le.data)==null?void 0:lc.userId);if(dc&&localStorage.setItem("backflow_refresh_user_id",dc),!mt&&(Pe||ee.current||!!ue.current)){window.location.reload();return}ee.current=!1,he(!0),ae(!1),j(!1),en(""),He(""),gs(""),bs({}),ie(null)}catch(xn){const Qi=typeof xn=="string"?xn:(xn==null?void 0:xn.message)||JSON.stringify(xn)||"Authentication failed";ie(Qi),jt(Qi,"error")}finally{sn(!1)}},v=async()=>{if(!Ot)return;const st=gn(Ot);if(st){ie(st);return}sn(!0),ie(null);try{const pt=await fetch("/api/auth/forgot-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Ot})});if(!pt.ok){const Tt=await pt.json().catch(()=>({error:"Failed to send reset email"}));throw new Error(le(Tt))}fn("reset"),pn(""),He(""),ie(null)}catch(pt){const Tt=typeof pt=="string"?pt:(pt==null?void 0:pt.message)||"Failed to send reset email";ie(Tt),jt(Tt,"error")}finally{sn(!1)}},b=async()=>{if(!mn||!Ft)return;const st=tt(Ft);if(st){ie(st);return}sn(!0),ie(null);try{const pt=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:mn,password:Ft})});if(!pt.ok){const Tt=await pt.json().catch(()=>({error:"Failed to reset password"}));throw new Error(le(Tt))}fn("login"),en(""),He(""),pn(""),ie(null)}catch(pt){const Tt=typeof pt=="string"?pt:(pt==null?void 0:pt.message)||"Failed to reset password";ie(Tt),jt(Tt,"error")}finally{sn(!1)}},_=st=>{fn(st),ie(null),st!=="reset"&&(pn(""),He("")),gs(""),bs({})},M=Et.colorMode==="dark",A=M?"#f3f4f6":"#111827",R=M?"#9ca3af":"#6b7280",$=M?"#374151":"#f3f4f6",N=M?"#4b5563":"#d1d5db",F=M?"#ffffff":"#000000",Y=M?"#000000":"#ffffff",G=M?"#1f2937":"#ffffff",W="#ef4444",et=(st="12px")=>({width:"100%",padding:"12px 16px",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"14px",backgroundColor:$,color:A,outline:"none",marginBottom:st,boxSizing:"border-box"}),B=(st,pt,Tt,Ye,On,Un)=>m.createElement("div",{key:st,style:{position:"relative",marginBottom:"12px"}},E("input",{key:"input",type:ys[st]?"text":"password",placeholder:pt,value:Tt,onChange:Ce=>Ye(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&On()},style:{...et("0px"),paddingRight:"40px",borderColor:Un?W:N}}),m.createElement("button",{key:"toggle",type:"button","aria-label":ys[st]?"Hide password":"Show password",onClick:()=>bs(Ce=>({...Ce,[st]:!Ce[st]})),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:R,display:"flex",alignItems:"center",padding:"4px"}},Ve.renderIcon(ys[st]?"eye-off":"eye",16)));l||e!=null&&e.title;const Z=(Se=e==null?void 0:e.config)!=null&&Se.logo&&((de=e==null?void 0:e.config)==null?void 0:de.logo)!==""?e.config.logo:"",dt=c||((ii=e==null?void 0:e.navigation)==null?void 0:ii.logo)||"mail",z=[];z.push(m.createElement("div",{key:"brand",role:"button","aria-label":"Go back home",onClick:()=>{on("/"),ae(!1),ee.current=!1,ue.current=null},style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"20px",cursor:"pointer"}},Z?m.createElement("img",{src:Z,alt:"",style:{width:"56px",height:"56px",objectFit:"contain"}}):Ve.renderIcon(dt,56))),We==="login"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Sign In")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter your credentials to continue")),z.push(E("input",{key:"email",type:"email",placeholder:"Email Address",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},style:{...et(),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),z.push(B("pass","Password",Ft,st=>{He(st),It("pass",tt(st))},y,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:y,disabled:re||!Ot||!Ft,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"8px"}},re?"Please wait...":"Sign In")),z.push(m.createElement("p",{key:"forgot",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer",marginBottom:"16px"},onClick:()=>_("forgot")},"Forgot password?")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("register")},"Don’t have an account? Register"))):We==="register"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Create Account")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Create an account to get started")),z.push(E("input",{key:"email",type:"email",placeholder:"Email",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},style:{...et(),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),z.push(B("pass","Password",Ft,st=>{He(st),It("pass",tt(st))},y,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),z.push(B("confirm","Confirm password",nn,st=>{gs(st),It("confirm",Yt(Ft,st))},y,!!(Wt.confirm&&nn))),Wt.confirm&&nn&&z.push(m.createElement("p",{key:"confirm-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.confirm)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:y,disabled:re||!Ot||!Ft||!nn,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Create Account")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Already have an account? Sign In"))):We==="forgot"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Reset Password")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter your email to receive a reset link")),z.push(E("input",{key:"email",type:"email",placeholder:"Email",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},onKeyDown:st=>{st.key==="Enter"&&v()},style:{...et("16px"),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:v,disabled:re||!Ot,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Send Reset Link")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Back to Sign In"))):We==="reset"&&(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Set New Password")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter the reset code and your new password")),z.push(E("input",{key:"code",type:"text",placeholder:"Reset code",value:mn,onChange:st=>pn(st.target.value),style:et()})),z.push(B("pass","New password",Ft,st=>{He(st),It("pass",tt(st))},b,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:b,disabled:re||!mn||!Ft,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Reset Password")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Back to Sign In")));const at=((Xi=e==null?void 0:e.config)==null?void 0:Xi.auth)||{},rt=at.style==="page"?"page":"modal",At=at.containerStyle||{},$t=m.createElement("div",{key:"auth-box",style:{width:"100%",maxWidth:rt==="page"?"400px":"360px",padding:"24px",backgroundColor:"#000000",borderRadius:"12px",...At}},...z);if(rt==="page"){const st=((Qt=Et.colors)==null?void 0:Qt.primary)||"#4f46e5",pt=at.coverImage?`url(${at.coverImage}) center/cover no-repeat`:st,Tt=(_t=e==null?void 0:e.config)!=null&&_t.logo&&((Jt=e==null?void 0:e.config)==null?void 0:Jt.logo)!==""?e.config.logo:"",Ye=Tt?m.createElement("img",{src:Tt,alt:"",style:{position:"absolute",bottom:"-6%",left:"50%",width:"90%",maxWidth:"660px",height:"auto",objectFit:"contain",transform:"translateX(-50%) rotate(-8deg)",opacity:.92,filter:"brightness(0) invert(1)"}}):m.createElement("div",{style:{color:"#ffffff",opacity:.95}},Ve.renderIcon(dt,96));return m.createElement("div",{key:"auth-page",style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",backgroundColor:G,zIndex:1e4,animation:"bf-fade-in 0.2s ease"}},m.createElement("div",{style:{flex:ps?"1 1 100%":"0 0 40%",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",backgroundColor:"#000000"}},$t),m.createElement("div",{style:{flex:"0 0 60%",background:pt,display:ps?"none":"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden"}},Ye))}return m.createElement("div",{key:"auth-form",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},$t)},ro=async(y,v,b)=>{var _,M;try{let A=String(ao(y)??"");const R=A.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);R&&(A=Fl(R[1])?R[2]:R[3]);const $=A.split(";").map(B=>B.trim()).filter(Boolean);if($.length>1){for(const B of $)await ro(B,void 0,b);return}if(A==="go_back"){In();return}if(A==="toggle_theme"){Rl((Pt._colorMode||Et.colorMode)==="dark"?"light":"dark");return}if(A==="close_modal"){Bn();return}const N=A.match(/^(toast|show_toast):(.*)$/);if(N){const B=N[2].trim();B&&jt(B,"success");return}const F=A.match(/^scroll_to:([\w-]+)$/);if(F){(_=document.getElementById(F[1]))==null||_.scrollIntoView({behavior:"smooth",block:"start"});return}const Y=A.match(/^set_data:([\w.]+)=(.*)$/);if(Y){St(B=>({...B,[Y[1]]:Y[2]}));return}const G=A.match(/^native:([a-z][\w.-]*)$/i);if(G){if(!i){jt("Native app required","error");return}const B=G[1],Z=await i(B,Pt);if(Z&&typeof Z=="object"&&!Array.isArray(Z)){const dt=B.replace(/[^\w]/g,"_");St(z=>({...z,native:{...z.native||{},[dt]:Z}}))}return}const W=A.match(/^copy_to_clipboard:(.*)$/);if(W){const B=W[1];try{await navigator.clipboard.writeText(B)}catch{const Z=document.createElement("textarea");Z.value=B,Z.style.position="fixed",Z.style.opacity="0",document.body.appendChild(Z),Z.select(),document.execCommand("copy"),Z.remove()}jt("API key copied","success");return}const et=A.match(/^auth:(login|register|forgot|reset|logout)$/);if(et){if(et[1]==="logout"){if(!mt)return;localStorage.removeItem("token"),localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),ee.current=!1,ue.current=null,he(!1),ae(!1),nt(null),j(!1),on("/");return}if(mt)return;ie(null),fn(et[1]),ae(!0);return}if(A==="accept_startup_modal"){const B=Et.startupModal;B&&localStorage.setItem(`backflow_startup_modal_${B}`,"1"),Bn();const Z=Q.find(dt=>dt.route==="/");Z&&(kt(dt=>[...dt,ot]),Me(Z.id));return}if(A==="decline_startup_modal"){Bn();const B=Q.find(Z=>Z.route==="/");B&&(kt(Z=>[...Z,ot]),Me(B.id));return}if(A==="toggle_select"){St(B=>({...B,_selectMode:!B._selectMode,...B._selectMode?{_selIds:[]}:{}}));return}if(A.startsWith("go_to_step:"))on(A.replace("go_to_step:","")),ws(v,!0);else if(A.startsWith("navigate:"))on(A.replace("navigate:","")),ws(v,!0);else if(Ci(A)&&t){const B=pi(A),Z=await Mr(t,B,Pt);Z!=null&&Z.data?St(dt=>({...dt,...Z.data})):Z&&typeof Z=="object"&&!Array.isArray(Z)&&St(dt=>({...dt,...Z})),Z!=null&&Z.url&&String(Z.url).startsWith("http")&&window.open(String(Z.url),"_blank","noopener,noreferrer"),ws(v,!0)}else if(A.startsWith("show_modal:")){const B=A.replace("show_modal:","");if(Gt[B]){const Z=Gt[B];if(fs(Z.popover&&(b!=null&&b.anchorElement)?b.anchorElement.getBoundingClientRect():null),ms.current=Z.popover&&(b==null?void 0:b.anchorElement)||null,yn.current&&typeof yn.current=="object"){const at=Object.keys(yn.current);St(rt=>{const At={...rt};for(const $t of no.current)at.includes($t)||delete At[$t];return{...At,...yn.current}}),no.current=at}const dt=Z.clearFormKeys;Array.isArray(dt)&&dt.length>0&&St(at=>{const rt={...at};for(const At of dt)delete rt[At];return rt});const z=Z.defaults;z&&typeof z=="object"&&St(at=>{const rt={...at};for(const[At,$t]of Object.entries(z))rt[At]===void 0&&(rt[At]=$t);return rt}),Z.preload&&await ni(String(Z.preload)),(zt==null?void 0:zt.id)===B||(_e==null?void 0:_e.id)===B||(zt?Wn({id:B,definition:Z}):se({id:B,definition:Z}))}else{const Z=B.split("|");se({id:"__legacy",definition:{title:Z[0]||"Notice",components:Z[1]?[{type:"text",text:Z[1],color:"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}ws(v,!0)}else A.startsWith("execute_workflow:")?(await ni(A.replace("execute_workflow:",""),b),ws(v,!0)):A.startsWith("fetch:")&&(await ni(A.replace("fetch:",""),b),r==null||r(A.replace("fetch:","")),ws(v,!0))}catch(A){if(gr("[handleButtonClick] caught error:",A,"callbacks:",v),A instanceof xs){if(io(A,v==null?void 0:v.onError))return;jt(A.errors.length>1?A.errors:A.errors[0],"error")}else(M=v==null?void 0:v.onError)!=null&&M.message?jt(v.onError.message,"error"):jt(A instanceof Error?A.message:"An error occurred","error")}},Il=y=>{const v=y&&typeof y=="object"&&"_seconds"in y?new Date(y._seconds*1e3):new Date(y);if(isNaN(v.getTime()))return String(y??"");const b=Math.floor((Date.now()-v.getTime())/6e4);if(b<1)return"just now";if(b<60)return`${b}m ago`;const _=Math.floor(b/60);if(_<24)return`${_}h ago`;const M=Math.floor(_/24);return M<7?`${M}d ago`:v.toLocaleDateString()},jn=(y,v)=>{if(v==="timeago")return Il(y);const b=y&&typeof y=="object"&&"_seconds"in y?new Date(y._seconds*1e3):new Date(y);if(!isNaN(b.getTime())){if(v==="date")return b.toLocaleDateString();if(v==="time")return b.toLocaleTimeString();if(v==="datetime")return b.toLocaleString()}return String(y??"")},ce=m.useRef({}),bn=y=>{const v=y.split(".").filter(Boolean);if(v.length===0)return;let b=ce.current[v[0]]??Pt[v[0]];for(let _=1;_<v.length;_++){if(b==null)return;const M=v[_];if(Array.isArray(b))if(M==="first")b=b[0];else if(M==="last")b=b[b.length-1];else if(M==="length")b=b.length;else if(/^\d+$/.test(M))b=b[Number(M)];else if(M==="index")b=b[0];else return;else if(b&&typeof b=="object"&&Array.isArray(b.items))M==="response"?b=b.response:M==="first"?b=b.items[0]:M==="last"?b=b.items[b.items.length-1]:M==="length"?b=b.items.length:/^\d+$/.test(M)?b=b.items[Number(M)]:M==="index"?b=b.items[0]:b=b[M];else if(typeof b=="object")b=b[M];else return}return b},oo=m.useRef({}),[Dl,Ll]=m.useState({}),Pm=m.useCallback(y=>(oo.current[y]||(oo.current[y]=import(y).catch(()=>fetch(y).then(v=>v.text()).then(v=>{const b={};return new Function("module","exports",v)(b,b),b.exports||b}))),oo.current[y]),[]),zl=(y,v,b,_)=>{if(!y)return"";if(y.startsWith("sdk:")){const R=b||"",$=Dl[R];if(R&&$!==void 0)return $;const N=y.slice(4);return t&&Mr(t,N,{...Pt,$data:ce.current}).then(F=>{ge.current||(_&&(ce.current[_]=F),Ll(Y=>({...Y,[R]:String(F??"")})))}).catch(()=>{}),""}const M=y.match(/^([A-Za-z_]\w*)\s*\(\s*(.*?)\s*\)$/s);if(M){const R=M[1],$=zl(M[2]);if(v){const N=Dl[b||""];return b&&N!==void 0?N:(Pm(v).then(F=>{var G,W;const Y=F&&(F[R]||((G=F.default)==null?void 0:G[R])||((W=F.exports)==null?void 0:W[R]))||(typeof F=="function"?F:void 0);typeof Y=="function"&&b&&Promise.resolve(Y($,{data:ce.current})).then(et=>{ge.current||(_&&(ce.current[_]=et),Ll(B=>({...B,[b]:String(et??"")})))})}).catch(()=>{}),"")}return R==="timeago"?Il($):R==="date"?jn($,"date"):R==="time"?jn($,"time"):R==="datetime"?jn($,"datetime"):R==="upper"?String($).toUpperCase():R==="lower"?String($).toLowerCase():String($??"")}if(y.startsWith("{{")&&y.endsWith("}}")){const $=y.slice(2,-2).trim().split("|").map(G=>G.trim()),N=$[0],F=$[1],Y=N.startsWith("{")&&N.endsWith("}")?bn(N.slice(1,-1)):N.startsWith("$")?bn(N.slice(1)):Pt[N];return F?jn(Y,F):String(Y??"")}if(y.startsWith("{")&&y.endsWith("}"))return String(bn(y.slice(1,-1))??"");const A=y.trim();return/^[A-Za-z_][\w.-]*$/.test(A)?String(bn(A)??""):String(y??"")},ao=y=>y?y.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+(?:\|\w+)?))?\s*(?:\|\|\s*(.+?))?\}\}/g,(v,b,_,M)=>{let A,R=_;if(_!=null&&_.includes("|")){const N=_.split("|");R=N[0],A=N[1]}const $=bn(R?`${b}.${R}`:b);if($!=null){const N=A?jn($,A):$;return Array.isArray(N)||typeof N=="object"?JSON.stringify(N):String(N)}return M!==void 0?M.replace(/^["']|["']$/g,""):""}).replace(/\{\{(\w+(?:\.\w+)*)\s*(?:\|(date|time|datetime|timeago)\s*)?(?:\|\|\s*(.+?))?\}\}/g,(v,b,_,M)=>{const A=b.split(".");let R=Pt;for(const $ of A)R=R==null?void 0:R[$];if(R!==void 0)return _?jn(R,_):String(R);if(yn.current){let $=yn.current;for(const N of A)$=$==null?void 0:$[N];if($!==void 0)return _?jn($,_):String($)}if(A[0]==="config"){let $=e==null?void 0:e.config;for(const N of A.slice(1))$=$==null?void 0:$[N];if($!==void 0)return String($)}return M!==void 0?M.replace(/^["']|["']$/g,""):""}):"",Ui=(y,v)=>{if(!y)return!0;const b=A=>{var $;if(A==="auth"){const N=($=e==null?void 0:e.auth)==null?void 0:$.signedIn;return N===void 0?mt:N}if(A.startsWith("[")&&A.includes("]")){const N=A.indexOf("]"),F=ce.current[A.slice(1,N)],Y=A.slice(N+1).replace(/^\./,"");let G;const W=Y.split(".").filter(Boolean);W[0]==="response"||W[0]==="items"?G=F:G=(F==null?void 0:F.items)??F;for(const et of W){if(G==null)return;Array.isArray(G)&&et==="length"?G=G.length:G=G==null?void 0:G[et]}return G}let R=v;for(const N of A.split("."))R=R==null?void 0:R[N];return R},_=y.trim();if(_.includes("||"))return _.split("||").some(A=>Ui(A,v));if(_.includes("&&"))return _.split("&&").every(A=>Ui(A,v));if(_.startsWith("!"))return!b(_.slice(1).trim());const M=_.match(/^(\[[^\]]+\](?:\.\w+)*|\w+(?:\.\w+)*)\s*(==|!=|>|<|>=|<=)\s*(.+)$/);if(M){const A=b(M[1]),R=M[3].trim().replace(/^["']|["']$/g,"");switch(M[2]){case"==":return String(A)===R;case"!=":return String(A)!==R;case">":return Number(A)>Number(R);case"<":return Number(A)<Number(R);case">=":return Number(A)>=Number(R);case"<=":return Number(A)<=Number(R)}}return!!b(_)},Fl=y=>Ui(y,Pt),_m=(y,v,b)=>{if(!u||h!==v&&!(a&&b&&a===b))return y;const M={...y};return u.size!==void 0&&(M.transform=`scale(${u.size/100})`,M.transformOrigin="center center"),u.spacing!==void 0&&(M.margin=`${u.spacing}px`),u.alignment&&(M.textAlign=u.alignment,u.alignment==="left"?(M.marginLeft="0",M.marginRight="auto"):u.alignment==="right"&&(M.marginLeft="auto",M.marginRight="0")),u.color&&(M.color=u.color),u.gridCols!==void 0&&(M.gridTemplateColumns=`repeat(${u.gridCols}, minmax(0, 1fr))`),u.gridGap!==void 0&&(M.gap=`${u.gridGap}px`),u.buttonBackground&&(M.background=u.buttonBackground),u.buttonTextColor&&(M.color=u.buttonTextColor),u.buttonBorderRadius!==void 0&&(M.borderRadius=`${u.buttonBorderRadius}px`),u.linkColor&&(M.color=u.linkColor),u.linkTextDecoration&&(M.textDecoration=u.linkTextDecoration),u.flexDirection&&(M.flexDirection=u.flexDirection),u.flexGap!==void 0&&(M.gap=`${u.flexGap}px`),M},$m=(y,v)=>{const b={...y};return v.scale!==void 0&&v.scale!==100&&(b.transform=`scale(${v.scale/100})`,b.transformOrigin="center center"),v.spacing!==void 0&&v.spacing!==0&&(b.margin=`${v.spacing}px`),v.alignment&&v.alignment!=="center"&&(b.textAlign=v.alignment,v.alignment==="left"?(b.marginLeft="0",b.marginRight="auto"):v.alignment==="right"&&(b.marginLeft="auto",b.marginRight="0")),v.color&&(b.color=v.color),v.background&&(b.backgroundColor=v.background),v.borderColor&&(b.borderColor=v.borderColor),b},Nm=(y,v,b)=>{const _=b==null?void 0:b.componentClass,A=h===y||a&&_&&a===_,R=b?$m(v,b):v,$=_m(R,y,_);b!=null&&b.fieldSpan&&b.fieldSpan>1&&($.gridColumn=`span ${b.fieldSpan} / span ${b.fieldSpan}`),b!=null&&b.rawStyle&&Object.assign($,b.rawStyle);const N=qt==="css-driven"?{"data-bf-r":`${we}-${y}`}:{};if(A){const Y=$.boxShadow?`${$.boxShadow}, `:"";return{"data-component-key":y,...N,style:{...$,boxShadow:`${Y}0 0 0 3px ${Et.colors.primary}`}}}return Object.keys($).length>0?{"data-component-key":y,...N,style:$}:{"data-component-key":y,...N}},Im=(y,v)=>{var R;if(!y)return{};const b=ba(y),_=y.split(/\s+/).filter($=>!/^(sm|md|lg|xl|2xl):/.test($)).join(" "),M=Dt(_||"flex");if(!ya(b))return M;if(qt==="css-driven"){const $={flexDirection:"fd",gap:"gap",width:"w",alignItems:"items",justifyContent:"justify",display:"display",fontSize:"text",borderRadius:"radius",padding:"p",paddingLeft:"px",paddingRight:"px",paddingTop:"py",paddingBottom:"py",margin:"m",marginTop:"mt",marginRight:"mr",marginBottom:"mb",marginLeft:"ml"},N=(F,Y)=>`var(--bf-${$[F]||F}-${v}, ${M[F]||Y})`;if(b.flexDirection.size>0&&(M.flexDirection=N("flexDirection","column")),b.gap.size>0&&(M.gap=N("gap","0px")),b.width.size>0&&(M.width=N("width","auto")),b.alignItems.size>0&&(M.alignItems=N("alignItems","stretch")),b.justifyContent.size>0&&(M.justifyContent=N("justifyContent","flex-start")),b.display.size>0&&(M.display=N("display","flex")),b.gridCols.size>0){const F=M.gridTemplateColumns||"1",Y=typeof F=="string"?(R=F.match(/^repeat\((\d+)/))==null?void 0:R[1]:F;M.gridTemplateColumns=`repeat(var(--bf-cols-${v}, ${Y||"1"}), minmax(0, 1fr))`}return b.textSize.size>0&&(M.fontSize=N("fontSize","1rem")),b.borderRadius.size>0&&(M.borderRadius=N("borderRadius","0px")),b.padding.p.size>0&&(M.padding=N("padding","0px")),b.padding.px.size>0&&(M.paddingLeft=N("paddingLeft","0px"),M.paddingRight=N("paddingRight","0px")),b.padding.py.size>0&&(M.paddingTop=N("paddingTop","0px"),M.paddingBottom=N("paddingBottom","0px")),b.margin.all.size>0&&(M.margin=N("margin","0px")),b.margin.t.size>0&&(M.marginTop=N("marginTop","0px")),b.margin.r.size>0&&(M.marginRight=N("marginRight","0px")),b.margin.b.size>0&&(M.marginBottom=N("marginBottom","0px")),b.margin.l.size>0&&(M.marginLeft=N("marginLeft","0px")),b.margin.x.size>0&&(M.marginLeft=N("marginLeft","0px"),M.marginRight=N("marginRight","0px")),b.margin.y.size>0&&(M.marginTop=N("marginTop","0px"),M.marginBottom=N("marginBottom","0px")),M}const A=Xt;if(b.flexDirection.size>0&&(M.flexDirection=ht(b.flexDirection,A,"column")),b.gap.size>0&&(M.gap=ht(b.gap,A,"0px")),b.width.size>0&&(M.width=ht(b.width,A,"auto")),b.alignItems.size>0&&(M.alignItems=ht(b.alignItems,A,"stretch")),b.justifyContent.size>0&&(M.justifyContent=ht(b.justifyContent,A,"flex-start")),b.display.size>0&&(M.display=ht(b.display,A,"flex")),b.gridCols.size>0){const $=ht(b.gridCols,A,1);M.gridTemplateColumns=`repeat(${$}, minmax(0, 1fr))`}return b.textSize.size>0&&(M.fontSize=ht(b.textSize,A,"1rem")),b.borderRadius.size>0&&(M.borderRadius=ht(b.borderRadius,A,"0px")),b.padding.p.size>0&&(M.padding=ht(b.padding.p,A,"0px")),b.padding.px.size>0&&(M.paddingLeft=ht(b.padding.px,A,"0px"),M.paddingRight=ht(b.padding.px,A,"0px")),b.padding.py.size>0&&(M.paddingTop=ht(b.padding.py,A,"0px"),M.paddingBottom=ht(b.padding.py,A,"0px")),b.margin.all.size>0&&(M.margin=ht(b.margin.all,A,"0px")),b.margin.t.size>0&&(M.marginTop=ht(b.margin.t,A,"0px")),b.margin.r.size>0&&(M.marginRight=ht(b.margin.r,A,"0px")),b.margin.b.size>0&&(M.marginBottom=ht(b.margin.b,A,"0px")),b.margin.l.size>0&&(M.marginLeft=ht(b.margin.l,A,"0px")),b.margin.x.size>0&&(M.marginLeft=ht(b.margin.x,A,"0px"),M.marginRight=ht(b.margin.x,A,"0px")),b.margin.y.size>0&&(M.marginTop=ht(b.margin.y,A,"0px"),M.marginBottom=ht(b.margin.y,A,"0px")),M},Bl=m.useRef(new Map),Dm=m.useCallback(async y=>{const v=Bl.current.get(y);if(v)return v;try{const b=s||localStorage.getItem("token")||"",_=await fetch(`/api/admin/schema?collection=${encodeURIComponent(y)}`,{headers:{Authorization:`Bearer ${b}`}});if(!_.ok)return null;const M=await _.json(),R=(Array.isArray(M)?M:Array.isArray(M==null?void 0:M.data)?M.data:[]).find($=>$.collection===y)||null;return Bl.current.set(y,R),R}catch{return null}},[s]),Ve={cfg:Et,sdk:t,renderMode:qt,scopeId:we,widgets:Array.isArray(e==null?void 0:e.widgets)?e.widgets:[],widgetStack:[],parseClassName:Dt,containerWidth:Xt,interactionDisabled:f,previewMode:U,isAuthenticated:mt,styleOverrides:u,selectedComponentKey:h,selectedComponentClass:a,sceneData:Pt,setSceneData:St,setColorMode:y=>Rl(y),portalTarget:gt.current,imageErrors:Js,setImageErrors:Ks,handleButtonClick:ro,interpolateText:ao,evaluateExpression:zl,evaluateCondition:Fl,showToast:jt,setActiveModal:se,dismissModal:Bn,setOverlayModal:Wn,dismissOverlayModal:Wi,fetchListData:Te,fetchEntitySchema:Dm,goBack:In,currentSceneId:ot,isMobileView:ps,navigateToScene:on,mobileMenuOpen:Zs,setMobileMenuOpen:ds,renderComponent:(y,v,b)=>Cr(Ve,y,v,b),renderIcon:(y,v,b)=>(n==null?void 0:n(y,v,b))??Ia(y,v,b),getCommonProps:Nm,imageReplacements:g,listData:Ln,rowContextRef:yn,uploadFile:Cm,runBulkSelectAction:km,selectDynamicOptions:Qs,setSelectDynamicOptions:ls,loading:tn,buttonLoading:hs,withLoading:Sm,paginationState:Ee,renderPhaserGame:P,parseClassNameResponsive:Im};let De=[];const Lm=m.useMemo(()=>{const y={};for(const[v,b]of Object.entries(Pt))v.startsWith("_")||(y[v]=b);return JSON.stringify(y)},[Pt]),Hi=m.useRef({}),lo=m.useRef(""),co=m.useRef({}),Wl=m.useRef(Ee);Wl.current=Ee;const Vl=m.useRef(tn);Vl.current=tn;const ho=m.useRef({}),uo=m.useRef(new Set),Ss=m.useRef(null);m.useEffect(()=>{if(!Vt||!mt){Be.current.forEach(v=>v()),Be.current.clear(),dn.current.clear();return}const y=v=>{var _;const b=v.getAttribute("data-bf-scroll-load");!b||uo.current.has(b)||(uo.current.add(b),(_=Ss.current)==null||_.observe(v))};Ss.current||(Ss.current=new IntersectionObserver(v=>{for(const b of v){if(!b.isIntersecting)continue;const _=b.target.getAttribute("data-bf-scroll-load");if(!_||ho.current[_])continue;const M=Wl.current[_],A=vs.current[_];if(!A||!(M!=null&&M.hasMore)||Vl.current[_])continue;ho.current[_]=!0;const R=co.current[_]||1;co.current[_]=R+1,Te(A,_,R,M.limit,void 0,void 0,void 0,!0).finally(()=>{var $;if(ho.current[_]=!1,b.target.isConnected){const N=b.target.getBoundingClientRect();N.bottom>-160&&N.top<(window.innerHeight||800)+160&&(($=Ss.current)==null||$.observe(b.target))}})}},{rootMargin:"160px 0px"})),document.querySelectorAll("[data-bf-scroll-load]").forEach(y)},[ot,Vt,Te,Ln,tn,Ee]),m.useEffect(()=>()=>{var y;(y=Ss.current)==null||y.disconnect(),Ss.current=null,uo.current=new Set},[ot]),m.useEffect(()=>{if(!Vt)return;const y=M=>typeof M=="string"?M.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*(?:\|\|\s*(.+?))?\}\}/g,(A,R,$,N)=>{const F=bn($?`${R}.${$}`:R);return F!=null?String(F):N!==void 0?N.replace(/^["']|["']$/g,""):""}).replace(/\{\{([\w.]+)\}\}/g,(A,R)=>{const $=R.split(".").reduce((N,F)=>N==null?void 0:N[F],Pt);return $!=null?String($):""}):"";lo.current!==ot&&(lo.current=ot);const v=(M,A="")=>{Array.isArray(M)&&M.forEach((R,$)=>{var G;const N=`${A}-${$}`;if((R.type==="list"||R.type==="table")&&R.dataSource){const W=y(R.dataSource),et=Hi.current[N]!==W;et&&(Hi.current[N]=W,co.current[N]=1,Te(W,N,0,R.pageSize||10,void 0,void 0,R.key));const B=R.realtime,Z=B?y(B.channel||""):"",dt=B?y(B.url||""):"",z=B?y(B.event||""):"",at=B?`${dt}|${Z}|${z}`:"",rt=dn.current.get(N)!==at;if(B&&(et||rt)){dn.current.set(N,at);const At=Be.current.get(N);At&&At();const $t=R.pageSize||10;let Se;const de=Qt=>{if(!B.bind)return;let _t=Qt;try{_t=typeof Qt=="string"?JSON.parse(Qt):Qt}catch{}B.bindField&&(!_t||_t[B.bindField]===void 0)||_t&&typeof _t=="object"&&St(Jt=>({...Jt,[B.bind]:_t}))},ii=Qt=>{if(!B.filter)return!0;let _t=Qt;if(typeof _t=="string")try{_t=JSON.parse(_t)}catch{return!1}return!_t||typeof _t!="object"?!1:Object.entries(B.filter).every(([Jt,st])=>_t[Jt]===st)},Xi=(Qt,_t)=>{if(!B.onEvent||!Array.isArray(_t))return;let Jt=Qt;if(typeof Jt=="string")try{Jt=JSON.parse(Jt)}catch{return}const st=Jt==null?void 0:Jt.id,pt=_t.find(Tt=>(Tt==null?void 0:Tt.id)===st);if(pt&&!(B.onEvent.when&&!Ui(B.onEvent.when,pt))){if(B.onEvent.once===!0){const Tt=[N,B.onEvent.action,B.onEvent.when||"",(pt==null?void 0:pt.id)||st||""].join(":");if(Fn.current.has(Tt))return;Fn.current.add(Tt)}yn.current=pt,no.current=Object.keys(pt),St(Tt=>({...Tt,...pt})),ro(B.onEvent.action,{}).catch(()=>{})}};switch(B.mode){case"poll":{const Qt=B.interval||5e3,_t=window.setInterval(()=>Te(W,N,0,$t),Qt);Se=()=>clearInterval(_t);break}case"sse":{if(!dt&&!Z){Se=()=>{};break}const Qt=s||localStorage.getItem("token")||"",_t=dt||`/events?channel=${Z}`,Jt=Qt&&!_t.includes("token=")?`${_t}${_t.includes("?")?"&":"?"}token=${encodeURIComponent(Qt)}`:_t,st=new EventSource(Jt),pt=Tt=>{ii(Tt.data)&&(de(Tt.data),Te(W,N,0,$t))};z?st.addEventListener(z,pt):st.onmessage=pt,st.onerror=()=>st.close(),Se=()=>st.close();break}case"ws":{if(!dt&&!Z){Se=()=>{};break}let Qt=null;const _t=()=>{var st;let Jt;if(Z&&((st=t==null?void 0:t.client)!=null&&st.createWebSocket))Jt=t.client.createWebSocket(Z);else{const pt=dt||`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?channel=${Z}`;Jt=new WebSocket(pt)}Jt.onmessage=pt=>{ii(pt.data)&&(de(pt.data),Te(W,N,0,$t).then(Tt=>{const Ye=Array.isArray(Tt)?Tt:Ln[N];B.onEvent&&Xi(pt.data,Ye);const On=Pt==null?void 0:Pt.id;if(On&&Array.isArray(Ye)&&lo.current===ot){const Un=Ye.find(Ce=>(Ce==null?void 0:Ce.id)===On);Un&&St(Ce=>({...Ce,...Un}))}}))},Jt.onclose=()=>setTimeout(_t,3e3),Qt=Jt};_t(),Se=()=>Qt==null?void 0:Qt.close();break}default:Se=()=>{}}Be.current.set(N,Se)}}if(R.type==="select"&&R.dataSource){const W=`${N}-sel`,et=y(R.dataSource);Hi.current[W]!==et&&(Hi.current[W]=et,(async()=>{try{const B=R.dataSource,Z=y(B),dt=await fetch(Z,{headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`}});if(!dt.ok)return;const z=await dt.json(),at=R.dataField||"configs",rt=R.optionLabel||"label",At=R.optionValue||"value",$t=z[at]||z.data||z,Se=Array.isArray($t)?$t.map(de=>({label:de[rt]||de.name||de.label,value:de[At]||de.id||de.name||de.label})):[];ls(de=>({...de,[N]:Se}))}catch{}})())}R.children&&v(R.children,N);const F=R.accordionItems||(R.type==="accordion"?R.items:null);Array.isArray(F)&&F.forEach((W,et)=>{Array.isArray(W==null?void 0:W.content)&&v(W.content,`${N}-acc-${et}-content`)}),Array.isArray(R.tabItems)&&R.tabItems.forEach((W,et)=>{const B=Array.isArray(W==null?void 0:W.content)?W.content:Array.isArray(W==null?void 0:W.children)?W.children:null;B&&v(B,`${N}-tabcontent-${et}`)});const Y=R;if(Y.type==="widget"&&Y.widgetId){const W=(G=e==null?void 0:e.widgets)==null?void 0:G.find(et=>et.id===Y.widgetId);W&&Array.isArray(W.components)&&v(W.components,`${N}-${Y.widgetId}`)}})};v(De);const b=zt||_e,_=b?Gt==null?void 0:Gt[b.id]:void 0;_&&Array.isArray(_==null?void 0:_.components)&&v(_.components,"modal")},[ot,Te,Lm,zt==null?void 0:zt.id,_e==null?void 0:_e.id,mt]),m.useEffect(()=>()=>{Be.current.forEach(y=>y()),Be.current.clear()},[ot]);const fo=m.useMemo(()=>{if(!Vt||qt!=="css-driven")return null;const y=new Map,v=(b,_)=>{b.forEach((M,A)=>{const R=`${_}-${A}`;if(M.className){const $=ba(M.className);if(ya($)){const N=gm(we,R,$);N&&y.set(R,N)}}M.children&&v(M.children,R)})};return v(De,""),y},[ot,De,qt,we]),jl=m.useRef(so);jl.current=so;const Cs=Et.realtime,Ol=Cs==null?void 0:Cs.mode,qi=Cs==null?void 0:Cs.url;if(m.useEffect(()=>{if(!mt||Ol!=="sse"||!qi)return;const y=s||localStorage.getItem("token");if(!y)return;let v=null,b=!1;return(async()=>{try{const _=L||window.location.origin,M=await fetch(`${_}${qi}/token`,{headers:{Authorization:`Bearer ${y}`}});if(!M.ok)return;const{token:A}=await M.json();if(!A||b)return;v=new EventSource(`${_}${qi}/subscribe?token=${encodeURIComponent(A)}`),v.onmessage=R=>{try{const $=JSON.parse(R.data);$!=null&&$.message&&jl.current($,"success")}catch{}},v.onerror=()=>v==null?void 0:v.close()}catch{}})(),()=>{b=!0,v==null||v.close()}},[mt,L,s,Ol,qi]),!Vt)return m.createElement(m.Fragment,null,uS(ft,Lt.length,In,C));const Mt=Vt,si=Mt.backgroundColor,Ul=si&&Ko(si)!==(Et.colorMode==="dark"?"dark":"light")?Ko(si)==="dark"?ki.text:Mi.text:Et.colors.text,Gi=Mt.height!==void 0?typeof Mt.height=="number"?`${Mt.height}px`:Mt.height:void 0,Yi=Mt.minHeight!==void 0?typeof Mt.minHeight=="number"?`${Mt.minHeight}px`:Mt.minHeight:void 0,zm=Mt.className?{...zu,display:"flex",flexDirection:"column",width:"100%",maxWidth:"100%",position:"relative",...Gi?{height:Gi}:{},...Yi?{minHeight:Yi}:{},backgroundColor:si||Et.colors.background,color:Ul,...Dt(Mt.className)}:{...zu,display:"flex",flexDirection:"column",position:"relative",width:"100%",maxWidth:"100%",...Gi?{height:Gi}:{},...Yi?{minHeight:Yi}:{},backgroundColor:si||Et.colors.background,color:Ul},Hl=Array.isArray(Mt.components)?Mt.components:[],Fm=hS(we),ql=(Vt==null?void 0:Vt.requireAuth)===!0||(Mt==null?void 0:Mt.requiresAuth)===!0||(qe==null?void 0:qe.requiresAuth)===!0||((Zl=qe==null?void 0:qe.config)==null?void 0:Zl.requiresAuth)===!0,Bm=(ql||Pe)&&!mt?Rm():null,Wm=mt&&ql&&J===!1&&!Nn?m.createElement("div",{key:"email-banner",style:{position:"fixed",top:0,left:0,right:0,zIndex:9500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 40px",backgroundColor:Et.colorMode==="dark"?"#78350f":"#fef3c7",color:Et.colorMode==="dark"?"#fef3c7":"#92400e",fontSize:"13px",fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},Ve.renderIcon("alert-triangle",14),m.createElement("span",null,"Verify your email — check your inbox for the confirmation link."),m.createElement("button",{"aria-label":"Dismiss",onClick:()=>Ys(!0),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"inherit",display:"flex",alignItems:"center",padding:"4px"}},Ve.renderIcon("x",16))):null,vn=e,Gl=Array.isArray(vn==null?void 0:vn.widgets)?vn.widgets:[],Yl=new Set,mo=y=>{if(Array.isArray(y))for(const v of y)v&&v.type==="widget"&&v.widgetId&&Yl.add(v.widgetId),v&&Array.isArray(v.children)&&mo(v.children)};mo(Hl);for(const y of Gl)mo(y.components);const Vm=Gl.filter(y=>Yl.has(y.id)?!1:y.sceneIds==="*"?!0:Array.isArray(y.sceneIds)?y.sceneIds.includes("*")||y.sceneIds.includes(ot):!1);De=[...Hl],(ec=(tc=vn.layout)==null?void 0:tc.header)!=null&&ec.length?De.splice(0,0,...vn.layout.header):(sc=(nc=Mt==null?void 0:Mt.layout)==null?void 0:nc.header)!=null&&sc.length&&De.splice(0,0,...Mt.layout.header);for(const y of Vm||[]){const v=y.components||[];if(!v.length)continue;if(y.targetKey){const _=y.targetKey.split("-").filter(Boolean).map(Number);if(_.length>0){let M=De,A=_[0];for(let $=0;$<_.length-1;$++){const N=M[_[$]];if(!N||!Array.isArray(N.children))break;M=N.children,A=_[$+1]}const R=y.targetPosition||"before";if(R==="inside"){const $=M[A];$&&(Array.isArray($.children)||($.children=[]),$.children.unshift(...v))}else R==="after"?M.splice(A+1,0,...v):M.splice(A,0,...v);continue}}const b=y.index??De.length;De.splice(b,0,...v)}(rc=(ic=vn.layout)==null?void 0:ic.footer)!=null&&rc.length?De.push(...vn.layout.footer):(ac=(oc=Mt==null?void 0:Mt.layout)==null?void 0:oc.footer)!=null&&ac.length&&De.push(...Mt.layout.footer);const jm=fo&&fo.size>0?m.createElement("style",{key:"bf-responsive"},Array.from(fo.values()).join(`
|
|
92
|
-
`)):null,
|
|
91
|
+
`):dt},dismiss:Z}},Ss=(y,v=!0)=>{if(v&&(y!=null&&y.onSuccess)){const b=Array.isArray(y.onSuccess)?y.onSuccess:[y.onSuccess];for(const _ of b){const{type:M,value:A,title:R,key:$}=_;switch(M){case"toast":Vt(A||"Success!","success");break;case"navigate":A&&on(A);break;case"redirect":A&&(window.location.href=A);break;case"modal":A&&Gt[A]?se({id:A,definition:Gt[A]}):se({id:"__legacy",definition:{title:R||"Success",components:A?[{type:"text",text:A,color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}});break;case"route":A&&ni(A);break;case"set_data":$&&A!==void 0&&St(N=>({...N,[$]:A}));break}}}else!v&&(y!=null&&y.onError)&&Vt(y.onError.message||"An error occurred","error")},Pm=()=>{var Se,de,ii,Xi,Qt,_t,Jt;const y=async()=>{var Tt,Ye,Un,Hn,Ce,ac;if(!Ot||!Ft||We==="register"&&!nn)return;const st=gn(Ot),pt=tt(Ft);if(st||pt){ie(st||pt);return}if(We==="register"&&nn!==Ft){It("confirm","Passwords do not match"),ie("Passwords do not match");return}sn(!0),ie(null);try{const xn=We==="login"?"/auth/login":"/auth/register",Qi=`${Ge().replace(/\/+$/,"")}${xn}`,Qm=We==="login"?{email:Ot,password:Ft,tenantId:S}:{email:Ot,password:Ft,displayName:Ot.split("@")[0],tenantId:S},lc={"Content-Type":"application/json"};T&&(lc["x-app-id"]=T);const po=await fetch(Qi,{method:"POST",headers:lc,body:JSON.stringify(Qm)});if(!po.ok){const Jm=await po.json().catch(()=>({error:"Authentication failed"}));throw new Error(le(Jm))}const Le=await po.json();if(Array.isArray(Le)||Le.success===!1)throw new Error(le(Le));const cc=((Tt=Le.data)==null?void 0:Tt.token)||Le.token||Le.accessToken||Le.idToken;cc&&localStorage.setItem("token",cc);const hc=((Ye=Le.data)==null?void 0:Ye.refreshToken)||Le.refreshToken;hc&&localStorage.setItem("backflow_refresh_token",hc);const uc=((Hn=(Un=Le.data)==null?void 0:Un.user)==null?void 0:Hn.id)||((Ce=Le.user)==null?void 0:Ce.id)||((ac=Le.data)==null?void 0:ac.userId);if(uc&&localStorage.setItem("backflow_refresh_user_id",uc),!mt&&(Pe||ee.current||!!ue.current)){window.location.reload();return}ee.current=!1,he(!0),ae(!1),V(!1),en(""),He(""),ys(""),vs({}),ie(null)}catch(xn){const Qi=typeof xn=="string"?xn:(xn==null?void 0:xn.message)||JSON.stringify(xn)||"Authentication failed";ie(Qi),Vt(Qi,"error")}finally{sn(!1)}},v=async()=>{if(!Ot)return;const st=gn(Ot);if(st){ie(st);return}sn(!0),ie(null);try{const pt=await fetch("/api/auth/forgot-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Ot})});if(!pt.ok){const Tt=await pt.json().catch(()=>({error:"Failed to send reset email"}));throw new Error(le(Tt))}fn("reset"),pn(""),He(""),ie(null)}catch(pt){const Tt=typeof pt=="string"?pt:(pt==null?void 0:pt.message)||"Failed to send reset email";ie(Tt),Vt(Tt,"error")}finally{sn(!1)}},b=async()=>{if(!mn||!Ft)return;const st=tt(Ft);if(st){ie(st);return}sn(!0),ie(null);try{const pt=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:mn,password:Ft})});if(!pt.ok){const Tt=await pt.json().catch(()=>({error:"Failed to reset password"}));throw new Error(le(Tt))}fn("login"),en(""),He(""),pn(""),ie(null)}catch(pt){const Tt=typeof pt=="string"?pt:(pt==null?void 0:pt.message)||"Failed to reset password";ie(Tt),Vt(Tt,"error")}finally{sn(!1)}},_=st=>{fn(st),ie(null),st!=="reset"&&(pn(""),He("")),ys(""),vs({})},M=Et.colorMode==="dark",A=M?"#f3f4f6":"#111827",R=M?"#9ca3af":"#6b7280",$=M?"#374151":"#f3f4f6",N=M?"#4b5563":"#d1d5db",F=M?"#ffffff":"#000000",Y=M?"#000000":"#ffffff",G=M?"#1f2937":"#ffffff",W="#ef4444",et=(st="12px")=>({width:"100%",padding:"12px 16px",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"14px",backgroundColor:$,color:A,outline:"none",marginBottom:st,boxSizing:"border-box"}),B=(st,pt,Tt,Ye,Un,Hn)=>m.createElement("div",{key:st,style:{position:"relative",marginBottom:"12px"}},E("input",{key:"input",type:bs[st]?"text":"password",placeholder:pt,value:Tt,onChange:Ce=>Ye(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&Un()},style:{...et("0px"),paddingRight:"40px",borderColor:Hn?W:N}}),m.createElement("button",{key:"toggle",type:"button","aria-label":bs[st]?"Hide password":"Show password",onClick:()=>vs(Ce=>({...Ce,[st]:!Ce[st]})),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:R,display:"flex",alignItems:"center",padding:"4px"}},je.renderIcon(bs[st]?"eye-off":"eye",16)));l||e!=null&&e.title;const Z=(Se=e==null?void 0:e.config)!=null&&Se.logo&&((de=e==null?void 0:e.config)==null?void 0:de.logo)!==""?e.config.logo:"",dt=c||((ii=e==null?void 0:e.navigation)==null?void 0:ii.logo)||"mail",z=[];z.push(m.createElement("div",{key:"brand",role:"button","aria-label":"Go back home",onClick:()=>{on("/"),ae(!1),ee.current=!1,ue.current=null},style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"20px",cursor:"pointer"}},Z?m.createElement("img",{src:Z,alt:"",style:{width:"56px",height:"56px",objectFit:"contain"}}):je.renderIcon(dt,56))),We==="login"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Sign In")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter your credentials to continue")),z.push(E("input",{key:"email",type:"email",placeholder:"Email Address",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},style:{...et(),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),z.push(B("pass","Password",Ft,st=>{He(st),It("pass",tt(st))},y,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:y,disabled:re||!Ot||!Ft,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"8px"}},re?"Please wait...":"Sign In")),z.push(m.createElement("p",{key:"forgot",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer",marginBottom:"16px"},onClick:()=>_("forgot")},"Forgot password?")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("register")},"Don’t have an account? Register"))):We==="register"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Create Account")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Create an account to get started")),z.push(E("input",{key:"email",type:"email",placeholder:"Email",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},style:{...et(),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),z.push(B("pass","Password",Ft,st=>{He(st),It("pass",tt(st))},y,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),z.push(B("confirm","Confirm password",nn,st=>{ys(st),It("confirm",Yt(Ft,st))},y,!!(Wt.confirm&&nn))),Wt.confirm&&nn&&z.push(m.createElement("p",{key:"confirm-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.confirm)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:y,disabled:re||!Ot||!Ft||!nn,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Create Account")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Already have an account? Sign In"))):We==="forgot"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Reset Password")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter your email to receive a reset link")),z.push(E("input",{key:"email",type:"email",placeholder:"Email",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},onKeyDown:st=>{st.key==="Enter"&&v()},style:{...et("16px"),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:v,disabled:re||!Ot,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Send Reset Link")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Back to Sign In"))):We==="reset"&&(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Set New Password")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter the reset code and your new password")),z.push(E("input",{key:"code",type:"text",placeholder:"Reset code",value:mn,onChange:st=>pn(st.target.value),style:et()})),z.push(B("pass","New password",Ft,st=>{He(st),It("pass",tt(st))},b,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:b,disabled:re||!mn||!Ft,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Reset Password")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Back to Sign In")));const at=((Xi=e==null?void 0:e.config)==null?void 0:Xi.auth)||{},rt=at.style==="page"?"page":"modal",At=at.containerStyle||{},$t=m.createElement("div",{key:"auth-box",style:{width:"100%",maxWidth:rt==="page"?"400px":"360px",padding:"24px",backgroundColor:"#000000",borderRadius:"12px",...At}},...z);if(rt==="page"){const st=((Qt=Et.colors)==null?void 0:Qt.primary)||"#4f46e5",pt=at.coverImage?`url(${at.coverImage}) center/cover no-repeat`:st,Tt=(_t=e==null?void 0:e.config)!=null&&_t.logo&&((Jt=e==null?void 0:e.config)==null?void 0:Jt.logo)!==""?e.config.logo:"",Ye=Tt?m.createElement("img",{src:Tt,alt:"",style:{position:"absolute",bottom:"-6%",left:"50%",width:"90%",maxWidth:"660px",height:"auto",objectFit:"contain",transform:"translateX(-50%) rotate(-8deg)",opacity:.92,filter:"brightness(0) invert(1)"}}):m.createElement("div",{style:{color:"#ffffff",opacity:.95}},je.renderIcon(dt,96));return m.createElement("div",{key:"auth-page",style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",backgroundColor:G,zIndex:1e4,animation:"bf-fade-in 0.2s ease"}},m.createElement("div",{style:{flex:gs?"1 1 100%":"0 0 40%",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",backgroundColor:"#000000"}},$t),m.createElement("div",{style:{flex:"0 0 60%",background:pt,display:gs?"none":"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden"}},Ye))}return m.createElement("div",{key:"auth-form",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},$t)},ro=async(y,v,b)=>{var _,M;try{let A=String(ao(y)??"");const R=A.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);R&&(A=zl(R[1])?R[2]:R[3]);const $=A.split(";").map(B=>B.trim()).filter(Boolean);if($.length>1){for(const B of $)await ro(B,void 0,b);return}if(A==="go_back"){Dn();return}if(A==="toggle_theme"){Al((Pt._colorMode||Et.colorMode)==="dark"?"light":"dark");return}if(A==="close_modal"){Wn();return}const N=A.match(/^(toast|show_toast):(.*)$/);if(N){const B=N[2].trim();B&&Vt(B,"success");return}const F=A.match(/^scroll_to:([\w-]+)$/);if(F){(_=document.getElementById(F[1]))==null||_.scrollIntoView({behavior:"smooth",block:"start"});return}const Y=A.match(/^set_data:([\w.]+)=(.*)$/);if(Y){St(B=>({...B,[Y[1]]:Y[2]}));return}const G=A.match(/^native:([a-z][\w.-]*)$/i);if(G){if(!i){Vt("Native app required","error");return}const B=G[1],Z=await i(B,Pt);if(Z&&typeof Z=="object"&&!Array.isArray(Z)){const dt=B.replace(/[^\w]/g,"_");St(z=>({...z,native:{...z.native||{},[dt]:Z}}))}return}const W=A.match(/^copy_to_clipboard:(.*)$/);if(W){const B=W[1];try{await navigator.clipboard.writeText(B)}catch{const Z=document.createElement("textarea");Z.value=B,Z.style.position="fixed",Z.style.opacity="0",document.body.appendChild(Z),Z.select(),document.execCommand("copy"),Z.remove()}Vt("API key copied","success");return}const et=A.match(/^auth:(login|register|forgot|reset|logout)$/);if(et){if(et[1]==="logout"){if(!mt)return;localStorage.removeItem("token"),localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),ee.current=!1,ue.current=null,he(!1),ae(!1),nt(null),V(!1),on("/");return}if(mt)return;ie(null),fn(et[1]),ae(!0);return}if(A==="accept_startup_modal"){const B=Et.startupModal;B&&localStorage.setItem(`backflow_startup_modal_${B}`,"1"),Wn();const Z=Q.find(dt=>dt.route==="/");Z&&(kt(dt=>[...dt,ot]),Me(Z.id));return}if(A==="decline_startup_modal"){Wn();const B=Q.find(Z=>Z.route==="/");B&&(kt(Z=>[...Z,ot]),Me(B.id));return}if(A==="toggle_select"){St(B=>({...B,_selectMode:!B._selectMode,...B._selectMode?{_selIds:[]}:{}}));return}if(A.startsWith("go_to_step:"))on(A.replace("go_to_step:","")),Ss(v,!0);else if(A.startsWith("navigate:"))on(A.replace("navigate:","")),Ss(v,!0);else if(Ci(A)&&t){const B=pi(A),Z=await Mr(t,B,Pt);Z!=null&&Z.data?St(dt=>({...dt,...Z.data})):Z&&typeof Z=="object"&&!Array.isArray(Z)&&St(dt=>({...dt,...Z})),Z!=null&&Z.url&&String(Z.url).startsWith("http")&&window.open(String(Z.url),"_blank","noopener,noreferrer"),Ss(v,!0)}else if(A.startsWith("show_modal:")){const B=A.replace("show_modal:","");if(Gt[B]){const Z=Gt[B];if(ms(Z.popover&&(b!=null&&b.anchorElement)?b.anchorElement.getBoundingClientRect():null),ps.current=Z.popover&&(b==null?void 0:b.anchorElement)||null,yn.current&&typeof yn.current=="object"){const at=Object.keys(yn.current);St(rt=>{const At={...rt};for(const $t of no.current)at.includes($t)||delete At[$t];return{...At,...yn.current}}),no.current=at}const dt=Z.clearFormKeys;Array.isArray(dt)&&dt.length>0&&St(at=>{const rt={...at};for(const At of dt)delete rt[At];return rt});const z=Z.defaults;z&&typeof z=="object"&&St(at=>{const rt={...at};for(const[At,$t]of Object.entries(z))rt[At]===void 0&&(rt[At]=$t);return rt}),Z.preload&&await ni(String(Z.preload)),(zt==null?void 0:zt.id)===B||(_e==null?void 0:_e.id)===B||(zt?jn({id:B,definition:Z}):se({id:B,definition:Z}))}else{const Z=B.split("|");se({id:"__legacy",definition:{title:Z[0]||"Notice",components:Z[1]?[{type:"text",text:Z[1],color:"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}Ss(v,!0)}else A.startsWith("execute_workflow:")?(await ni(A.replace("execute_workflow:",""),b),Ss(v,!0)):A.startsWith("fetch:")&&(await ni(A.replace("fetch:",""),b),r==null||r(A.replace("fetch:","")),Ss(v,!0))}catch(A){if(gr("[handleButtonClick] caught error:",A,"callbacks:",v),A instanceof ws){if(io(A,v==null?void 0:v.onError))return;Vt(A.errors.length>1?A.errors:A.errors[0],"error")}else(M=v==null?void 0:v.onError)!=null&&M.message?Vt(v.onError.message,"error"):Vt(A instanceof Error?A.message:"An error occurred","error")}},Nl=y=>{const v=y&&typeof y=="object"&&"_seconds"in y?new Date(y._seconds*1e3):new Date(y);if(isNaN(v.getTime()))return String(y??"");const b=Math.floor((Date.now()-v.getTime())/6e4);if(b<1)return"just now";if(b<60)return`${b}m ago`;const _=Math.floor(b/60);if(_<24)return`${_}h ago`;const M=Math.floor(_/24);return M<7?`${M}d ago`:v.toLocaleDateString()},On=(y,v)=>{if(v==="timeago")return Nl(y);const b=y&&typeof y=="object"&&"_seconds"in y?new Date(y._seconds*1e3):new Date(y);if(!isNaN(b.getTime())){if(v==="date")return b.toLocaleDateString();if(v==="time")return b.toLocaleTimeString();if(v==="datetime")return b.toLocaleString()}return String(y??"")},ce=m.useRef({}),bn=y=>{const v=y.split(".").filter(Boolean);if(v.length===0)return;let b=ce.current[v[0]]??Pt[v[0]];for(let _=1;_<v.length;_++){if(b==null)return;const M=v[_];if(Array.isArray(b))if(M==="first")b=b[0];else if(M==="last")b=b[b.length-1];else if(M==="length")b=b.length;else if(/^\d+$/.test(M))b=b[Number(M)];else if(M==="index")b=b[0];else return;else if(b&&typeof b=="object"&&Array.isArray(b.items))M==="response"?b=b.response:M==="first"?b=b.items[0]:M==="last"?b=b.items[b.items.length-1]:M==="length"?b=b.items.length:/^\d+$/.test(M)?b=b.items[Number(M)]:M==="index"?b=b.items[0]:b=b[M];else if(typeof b=="object")b=b[M];else return}return b},oo=m.useRef({}),[Il,Dl]=m.useState({}),_m=m.useCallback(y=>(oo.current[y]||(oo.current[y]=import(y).catch(()=>fetch(y).then(v=>v.text()).then(v=>{const b={};return new Function("module","exports",v)(b,b),b.exports||b}))),oo.current[y]),[]),Ll=(y,v,b,_)=>{if(!y)return"";if(y.startsWith("sdk:")){const R=b||"",$=Il[R];if(R&&$!==void 0)return $;const N=y.slice(4);return t&&Mr(t,N,{...Pt,$data:ce.current}).then(F=>{ge.current||(_&&(ce.current[_]=F),Dl(Y=>({...Y,[R]:String(F??"")})))}).catch(()=>{}),""}const M=y.match(/^([A-Za-z_]\w*)\s*\(\s*(.*?)\s*\)$/s);if(M){const R=M[1],$=Ll(M[2]);if(v){const N=Il[b||""];return b&&N!==void 0?N:(_m(v).then(F=>{var G,W;const Y=F&&(F[R]||((G=F.default)==null?void 0:G[R])||((W=F.exports)==null?void 0:W[R]))||(typeof F=="function"?F:void 0);typeof Y=="function"&&b&&Promise.resolve(Y($,{data:ce.current})).then(et=>{ge.current||(_&&(ce.current[_]=et),Dl(B=>({...B,[b]:String(et??"")})))})}).catch(()=>{}),"")}return R==="timeago"?Nl($):R==="date"?On($,"date"):R==="time"?On($,"time"):R==="datetime"?On($,"datetime"):R==="upper"?String($).toUpperCase():R==="lower"?String($).toLowerCase():String($??"")}if(y.startsWith("{{")&&y.endsWith("}}")){const $=y.slice(2,-2).trim().split("|").map(G=>G.trim()),N=$[0],F=$[1],Y=N.startsWith("{")&&N.endsWith("}")?bn(N.slice(1,-1)):N.startsWith("$")?bn(N.slice(1)):Pt[N];return F?On(Y,F):String(Y??"")}if(y.startsWith("{")&&y.endsWith("}"))return String(bn(y.slice(1,-1))??"");const A=y.trim();return/^[A-Za-z_][\w.-]*$/.test(A)?String(bn(A)??""):String(y??"")},ao=y=>y?y.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+(?:\|\w+)?))?\s*(?:\|\|\s*(.+?))?\}\}/g,(v,b,_,M)=>{let A,R=_;if(_!=null&&_.includes("|")){const N=_.split("|");R=N[0],A=N[1]}const $=bn(R?`${b}.${R}`:b);if($!=null){const N=A?On($,A):$;return Array.isArray(N)||typeof N=="object"?JSON.stringify(N):String(N)}return M!==void 0?M.replace(/^["']|["']$/g,""):""}).replace(/\{\{(\w+(?:\.\w+)*)\s*(?:\|(date|time|datetime|timeago)\s*)?(?:\|\|\s*(.+?))?\}\}/g,(v,b,_,M)=>{const A=b.split(".");let R=Pt;for(const $ of A)R=R==null?void 0:R[$];if(R!==void 0)return _?On(R,_):String(R);if(yn.current){let $=yn.current;for(const N of A)$=$==null?void 0:$[N];if($!==void 0)return _?On($,_):String($)}if(A[0]==="config"){let $=e==null?void 0:e.config;for(const N of A.slice(1))$=$==null?void 0:$[N];if($!==void 0)return String($)}return M!==void 0?M.replace(/^["']|["']$/g,""):""}):"",Ui=(y,v)=>{if(!y)return!0;const b=A=>{var $;if(A==="auth"){const N=($=e==null?void 0:e.auth)==null?void 0:$.signedIn;return N===void 0?mt:N}if(A.startsWith("[")&&A.includes("]")){const N=A.indexOf("]"),F=ce.current[A.slice(1,N)],Y=A.slice(N+1).replace(/^\./,"");let G;const W=Y.split(".").filter(Boolean);W[0]==="response"||W[0]==="items"?G=F:G=(F==null?void 0:F.items)??F;for(const et of W){if(G==null)return;Array.isArray(G)&&et==="length"?G=G.length:G=G==null?void 0:G[et]}return G}let R=v;for(const N of A.split("."))R=R==null?void 0:R[N];return R},_=y.trim();if(_.includes("||"))return _.split("||").some(A=>Ui(A,v));if(_.includes("&&"))return _.split("&&").every(A=>Ui(A,v));if(_.startsWith("!"))return!b(_.slice(1).trim());const M=_.match(/^(\[[^\]]+\](?:\.\w+)*|\w+(?:\.\w+)*)\s*(==|!=|>|<|>=|<=)\s*(.+)$/);if(M){const A=b(M[1]),R=M[3].trim().replace(/^["']|["']$/g,"");switch(M[2]){case"==":return String(A)===R;case"!=":return String(A)!==R;case">":return Number(A)>Number(R);case"<":return Number(A)<Number(R);case">=":return Number(A)>=Number(R);case"<=":return Number(A)<=Number(R)}}return!!b(_)},zl=y=>Ui(y,Pt),$m=(y,v,b)=>{if(!u||h!==v&&!(a&&b&&a===b))return y;const M={...y};return u.size!==void 0&&(M.transform=`scale(${u.size/100})`,M.transformOrigin="center center"),u.spacing!==void 0&&(M.margin=`${u.spacing}px`),u.alignment&&(M.textAlign=u.alignment,u.alignment==="left"?(M.marginLeft="0",M.marginRight="auto"):u.alignment==="right"&&(M.marginLeft="auto",M.marginRight="0")),u.color&&(M.color=u.color),u.gridCols!==void 0&&(M.gridTemplateColumns=`repeat(${u.gridCols}, minmax(0, 1fr))`),u.gridGap!==void 0&&(M.gap=`${u.gridGap}px`),u.buttonBackground&&(M.background=u.buttonBackground),u.buttonTextColor&&(M.color=u.buttonTextColor),u.buttonBorderRadius!==void 0&&(M.borderRadius=`${u.buttonBorderRadius}px`),u.linkColor&&(M.color=u.linkColor),u.linkTextDecoration&&(M.textDecoration=u.linkTextDecoration),u.flexDirection&&(M.flexDirection=u.flexDirection),u.flexGap!==void 0&&(M.gap=`${u.flexGap}px`),M},Nm=(y,v)=>{const b={...y};return v.scale!==void 0&&v.scale!==100&&(b.transform=`scale(${v.scale/100})`,b.transformOrigin="center center"),v.spacing!==void 0&&v.spacing!==0&&(b.margin=`${v.spacing}px`),v.alignment&&v.alignment!=="center"&&(b.textAlign=v.alignment,v.alignment==="left"?(b.marginLeft="0",b.marginRight="auto"):v.alignment==="right"&&(b.marginLeft="auto",b.marginRight="0")),v.color&&(b.color=v.color),v.background&&(b.backgroundColor=v.background),v.borderColor&&(b.borderColor=v.borderColor),b},Im=(y,v,b)=>{const _=b==null?void 0:b.componentClass,A=h===y||a&&_&&a===_,R=b?Nm(v,b):v,$=$m(R,y,_);b!=null&&b.fieldSpan&&b.fieldSpan>1&&($.gridColumn=`span ${b.fieldSpan} / span ${b.fieldSpan}`),b!=null&&b.rawStyle&&Object.assign($,b.rawStyle);const N=qt==="css-driven"?{"data-bf-r":`${we}-${y}`}:{};if(A){const Y=$.boxShadow?`${$.boxShadow}, `:"";return{"data-component-key":y,...N,style:{...$,boxShadow:`${Y}0 0 0 3px ${Et.colors.primary}`}}}return Object.keys($).length>0?{"data-component-key":y,...N,style:$}:{"data-component-key":y,...N}},Dm=(y,v)=>{var R;if(!y)return{};const b=ba(y),_=y.split(/\s+/).filter($=>!/^(sm|md|lg|xl|2xl):/.test($)).join(" "),M=Dt(_||"flex");if(!ya(b))return M;if(qt==="css-driven"){const $={flexDirection:"fd",gap:"gap",width:"w",alignItems:"items",justifyContent:"justify",display:"display",fontSize:"text",borderRadius:"radius",padding:"p",paddingLeft:"px",paddingRight:"px",paddingTop:"py",paddingBottom:"py",margin:"m",marginTop:"mt",marginRight:"mr",marginBottom:"mb",marginLeft:"ml"},N=(F,Y)=>`var(--bf-${$[F]||F}-${v}, ${M[F]||Y})`;if(b.flexDirection.size>0&&(M.flexDirection=N("flexDirection","column")),b.gap.size>0&&(M.gap=N("gap","0px")),b.width.size>0&&(M.width=N("width","auto")),b.alignItems.size>0&&(M.alignItems=N("alignItems","stretch")),b.justifyContent.size>0&&(M.justifyContent=N("justifyContent","flex-start")),b.display.size>0&&(M.display=N("display","flex")),b.gridCols.size>0){const F=M.gridTemplateColumns||"1",Y=typeof F=="string"?(R=F.match(/^repeat\((\d+)/))==null?void 0:R[1]:F;M.gridTemplateColumns=`repeat(var(--bf-cols-${v}, ${Y||"1"}), minmax(0, 1fr))`}return b.textSize.size>0&&(M.fontSize=N("fontSize","1rem")),b.borderRadius.size>0&&(M.borderRadius=N("borderRadius","0px")),b.padding.p.size>0&&(M.padding=N("padding","0px")),b.padding.px.size>0&&(M.paddingLeft=N("paddingLeft","0px"),M.paddingRight=N("paddingRight","0px")),b.padding.py.size>0&&(M.paddingTop=N("paddingTop","0px"),M.paddingBottom=N("paddingBottom","0px")),b.margin.all.size>0&&(M.margin=N("margin","0px")),b.margin.t.size>0&&(M.marginTop=N("marginTop","0px")),b.margin.r.size>0&&(M.marginRight=N("marginRight","0px")),b.margin.b.size>0&&(M.marginBottom=N("marginBottom","0px")),b.margin.l.size>0&&(M.marginLeft=N("marginLeft","0px")),b.margin.x.size>0&&(M.marginLeft=N("marginLeft","0px"),M.marginRight=N("marginRight","0px")),b.margin.y.size>0&&(M.marginTop=N("marginTop","0px"),M.marginBottom=N("marginBottom","0px")),M}const A=Xt;if(b.flexDirection.size>0&&(M.flexDirection=ht(b.flexDirection,A,"column")),b.gap.size>0&&(M.gap=ht(b.gap,A,"0px")),b.width.size>0&&(M.width=ht(b.width,A,"auto")),b.alignItems.size>0&&(M.alignItems=ht(b.alignItems,A,"stretch")),b.justifyContent.size>0&&(M.justifyContent=ht(b.justifyContent,A,"flex-start")),b.display.size>0&&(M.display=ht(b.display,A,"flex")),b.gridCols.size>0){const $=ht(b.gridCols,A,1);M.gridTemplateColumns=`repeat(${$}, minmax(0, 1fr))`}return b.textSize.size>0&&(M.fontSize=ht(b.textSize,A,"1rem")),b.borderRadius.size>0&&(M.borderRadius=ht(b.borderRadius,A,"0px")),b.padding.p.size>0&&(M.padding=ht(b.padding.p,A,"0px")),b.padding.px.size>0&&(M.paddingLeft=ht(b.padding.px,A,"0px"),M.paddingRight=ht(b.padding.px,A,"0px")),b.padding.py.size>0&&(M.paddingTop=ht(b.padding.py,A,"0px"),M.paddingBottom=ht(b.padding.py,A,"0px")),b.margin.all.size>0&&(M.margin=ht(b.margin.all,A,"0px")),b.margin.t.size>0&&(M.marginTop=ht(b.margin.t,A,"0px")),b.margin.r.size>0&&(M.marginRight=ht(b.margin.r,A,"0px")),b.margin.b.size>0&&(M.marginBottom=ht(b.margin.b,A,"0px")),b.margin.l.size>0&&(M.marginLeft=ht(b.margin.l,A,"0px")),b.margin.x.size>0&&(M.marginLeft=ht(b.margin.x,A,"0px"),M.marginRight=ht(b.margin.x,A,"0px")),b.margin.y.size>0&&(M.marginTop=ht(b.margin.y,A,"0px"),M.marginBottom=ht(b.margin.y,A,"0px")),M},Fl=m.useRef(new Map),Lm=m.useCallback(async y=>{const v=Fl.current.get(y);if(v)return v;try{const b=s||localStorage.getItem("token")||"",_=await fetch(`/api/admin/schema?collection=${encodeURIComponent(y)}`,{headers:{Authorization:`Bearer ${b}`}});if(!_.ok)return null;const M=await _.json(),R=(Array.isArray(M)?M:Array.isArray(M==null?void 0:M.data)?M.data:[]).find($=>$.collection===y)||null;return Fl.current.set(y,R),R}catch{return null}},[s]),je={cfg:Et,sdk:t,renderMode:qt,scopeId:we,widgets:Array.isArray(e==null?void 0:e.widgets)?e.widgets:[],widgetStack:[],parseClassName:Dt,containerWidth:Xt,interactionDisabled:f,previewMode:U,isAuthenticated:mt,styleOverrides:u,selectedComponentKey:h,selectedComponentClass:a,sceneData:Pt,setSceneData:St,setColorMode:y=>Al(y),portalTarget:gt.current,imageErrors:Js,setImageErrors:Ks,handleButtonClick:ro,interpolateText:ao,evaluateExpression:Ll,evaluateCondition:zl,showToast:Vt,setActiveModal:se,dismissModal:Wn,setOverlayModal:jn,dismissOverlayModal:Wi,fetchListData:Te,fetchEntitySchema:Lm,goBack:Dn,currentSceneId:ot,isMobileView:gs,navigateToScene:on,mobileMenuOpen:Zs,setMobileMenuOpen:fs,renderComponent:(y,v,b)=>Cr(je,y,v,b),renderIcon:(y,v,b)=>(n==null?void 0:n(y,v,b))??Na(y,v,b),getCommonProps:Im,imageReplacements:g,listData:zn,rowContextRef:yn,uploadFile:km,runBulkSelectAction:Mm,selectDynamicOptions:Qs,setSelectDynamicOptions:cs,loading:tn,buttonLoading:us,withLoading:Cm,paginationState:Ee,renderPhaserGame:P,parseClassNameResponsive:Dm};let De=[];const zm=m.useMemo(()=>{const y={};for(const[v,b]of Object.entries(Pt))v.startsWith("_")||(y[v]=b);return JSON.stringify(y)},[Pt]),Hi=m.useRef({}),lo=m.useRef(""),co=m.useRef({}),Bl=m.useRef(Ee);Bl.current=Ee;const Wl=m.useRef(tn);Wl.current=tn;const ho=m.useRef({}),uo=m.useRef(new Set),Cs=m.useRef(null);m.useEffect(()=>{if(!jt||!mt){Be.current.forEach(v=>v()),Be.current.clear(),dn.current.clear();return}const y=v=>{var _;const b=v.getAttribute("data-bf-scroll-load");!b||uo.current.has(b)||(uo.current.add(b),(_=Cs.current)==null||_.observe(v))};Cs.current||(Cs.current=new IntersectionObserver(v=>{for(const b of v){if(!b.isIntersecting)continue;const _=b.target.getAttribute("data-bf-scroll-load");if(!_||ho.current[_])continue;const M=Bl.current[_],A=xs.current[_];if(!A||!(M!=null&&M.hasMore)||Wl.current[_])continue;ho.current[_]=!0;const R=co.current[_]||1;co.current[_]=R+1,Te(A,_,R,M.limit,void 0,void 0,void 0,!0).finally(()=>{var $;if(ho.current[_]=!1,b.target.isConnected){const N=b.target.getBoundingClientRect();N.bottom>-160&&N.top<(window.innerHeight||800)+160&&(($=Cs.current)==null||$.observe(b.target))}})}},{rootMargin:"160px 0px"})),document.querySelectorAll("[data-bf-scroll-load]").forEach(y)},[ot,jt,Te,zn,tn,Ee]),m.useEffect(()=>()=>{var y;(y=Cs.current)==null||y.disconnect(),Cs.current=null,uo.current=new Set},[ot]),m.useEffect(()=>{if(!jt)return;const y=M=>typeof M=="string"?M.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*(?:\|\|\s*(.+?))?\}\}/g,(A,R,$,N)=>{const F=bn($?`${R}.${$}`:R);return F!=null?String(F):N!==void 0?N.replace(/^["']|["']$/g,""):""}).replace(/\{\{([\w.]+)\}\}/g,(A,R)=>{const $=R.split(".").reduce((N,F)=>N==null?void 0:N[F],Pt);return $!=null?String($):""}):"";lo.current!==ot&&(lo.current=ot);const v=(M,A="")=>{Array.isArray(M)&&M.forEach((R,$)=>{var G;const N=`${A}-${$}`;if((R.type==="list"||R.type==="table")&&R.dataSource){const W=y(R.dataSource),et=Hi.current[N]!==W;et&&(Hi.current[N]=W,co.current[N]=1,Te(W,N,0,R.pageSize||10,void 0,void 0,R.key));const B=R.realtime,Z=B?y(B.channel||""):"",dt=B?y(B.url||""):"",z=B?y(B.event||""):"",at=B?`${dt}|${Z}|${z}`:"",rt=dn.current.get(N)!==at;if(B&&(et||rt)){dn.current.set(N,at);const At=Be.current.get(N);At&&At();const $t=R.pageSize||10;let Se;const de=Qt=>{if(!B.bind)return;let _t=Qt;try{_t=typeof Qt=="string"?JSON.parse(Qt):Qt}catch{}B.bindField&&(!_t||_t[B.bindField]===void 0)||_t&&typeof _t=="object"&&St(Jt=>({...Jt,[B.bind]:_t}))},ii=Qt=>{if(!B.filter)return!0;let _t=Qt;if(typeof _t=="string")try{_t=JSON.parse(_t)}catch{return!1}return!_t||typeof _t!="object"?!1:Object.entries(B.filter).every(([Jt,st])=>_t[Jt]===st)},Xi=(Qt,_t)=>{if(!B.onEvent||!Array.isArray(_t))return;let Jt=Qt;if(typeof Jt=="string")try{Jt=JSON.parse(Jt)}catch{return}const st=Jt==null?void 0:Jt.id,pt=_t.find(Tt=>(Tt==null?void 0:Tt.id)===st);if(pt&&!(B.onEvent.when&&!Ui(B.onEvent.when,pt))){if(B.onEvent.once===!0){const Tt=[N,B.onEvent.action,B.onEvent.when||"",(pt==null?void 0:pt.id)||st||""].join(":");if(Bn.current.has(Tt))return;Bn.current.add(Tt)}yn.current=pt,no.current=Object.keys(pt),St(Tt=>({...Tt,...pt})),ro(B.onEvent.action,{}).catch(()=>{})}};switch(B.mode){case"poll":{const Qt=B.interval||5e3,_t=window.setInterval(()=>Te(W,N,0,$t),Qt);Se=()=>clearInterval(_t);break}case"sse":{if(!dt&&!Z){Se=()=>{};break}const Qt=s||localStorage.getItem("token")||"",_t=dt||`/events?channel=${Z}`,Jt=Qt&&!_t.includes("token=")?`${_t}${_t.includes("?")?"&":"?"}token=${encodeURIComponent(Qt)}`:_t,st=new EventSource(Jt),pt=Tt=>{ii(Tt.data)&&(de(Tt.data),Te(W,N,0,$t))};z?st.addEventListener(z,pt):st.onmessage=pt,st.onerror=()=>st.close(),Se=()=>st.close();break}case"ws":{if(!dt&&!Z){Se=()=>{};break}let Qt=null;const _t=()=>{var st;let Jt;if(Z&&((st=t==null?void 0:t.client)!=null&&st.createWebSocket))Jt=t.client.createWebSocket(Z);else{const pt=dt||`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?channel=${Z}`;Jt=new WebSocket(pt)}Jt.onmessage=pt=>{ii(pt.data)&&(de(pt.data),Te(W,N,0,$t).then(Tt=>{const Ye=Array.isArray(Tt)?Tt:zn[N];B.onEvent&&Xi(pt.data,Ye);const Un=Pt==null?void 0:Pt.id;if(Un&&Array.isArray(Ye)&&lo.current===ot){const Hn=Ye.find(Ce=>(Ce==null?void 0:Ce.id)===Un);Hn&&St(Ce=>({...Ce,...Hn}))}}))},Jt.onclose=()=>setTimeout(_t,3e3),Qt=Jt};_t(),Se=()=>Qt==null?void 0:Qt.close();break}default:Se=()=>{}}Be.current.set(N,Se)}}if(R.type==="select"&&R.dataSource){const W=`${N}-sel`,et=y(R.dataSource);Hi.current[W]!==et&&(Hi.current[W]=et,(async()=>{try{const B=R.dataSource,Z=y(B),dt=await fetch(Z,{headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`}});if(!dt.ok)return;const z=await dt.json(),at=R.dataField||"configs",rt=R.optionLabel||"label",At=R.optionValue||"value",$t=z[at]||z.data||z,Se=Array.isArray($t)?$t.map(de=>({label:de[rt]||de.name||de.label,value:de[At]||de.id||de.name||de.label})):[];cs(de=>({...de,[N]:Se}))}catch{}})())}R.children&&v(R.children,N);const F=R.accordionItems||(R.type==="accordion"?R.items:null);Array.isArray(F)&&F.forEach((W,et)=>{Array.isArray(W==null?void 0:W.content)&&v(W.content,`${N}-acc-${et}-content`)}),Array.isArray(R.tabItems)&&R.tabItems.forEach((W,et)=>{const B=Array.isArray(W==null?void 0:W.content)?W.content:Array.isArray(W==null?void 0:W.children)?W.children:null;B&&v(B,`${N}-tabcontent-${et}`)});const Y=R;if(Y.type==="widget"&&Y.widgetId){const W=(G=e==null?void 0:e.widgets)==null?void 0:G.find(et=>et.id===Y.widgetId);W&&Array.isArray(W.components)&&v(W.components,`${N}-${Y.widgetId}`)}})};v(De);const b=zt||_e,_=b?Gt==null?void 0:Gt[b.id]:void 0;_&&Array.isArray(_==null?void 0:_.components)&&v(_.components,"modal")},[ot,Te,zm,zt==null?void 0:zt.id,_e==null?void 0:_e.id,mt]),m.useEffect(()=>()=>{Be.current.forEach(y=>y()),Be.current.clear()},[ot]);const fo=m.useMemo(()=>{if(!jt||qt!=="css-driven")return null;const y=new Map,v=(b,_)=>{b.forEach((M,A)=>{const R=`${_}-${A}`;if(M.className){const $=ba(M.className);if(ya($)){const N=ym(we,R,$);N&&y.set(R,N)}}M.children&&v(M.children,R)})};return v(De,""),y},[ot,De,qt,we]),jl=m.useRef(so);jl.current=so;const ks=Et.realtime,Vl=ks==null?void 0:ks.mode,qi=ks==null?void 0:ks.url;if(m.useEffect(()=>{if(!mt||Vl!=="sse"||!qi)return;const y=s||localStorage.getItem("token");if(!y)return;let v=null,b=!1;return(async()=>{try{const _=L||window.location.origin,M=await fetch(`${_}${qi}/token`,{headers:{Authorization:`Bearer ${y}`}});if(!M.ok)return;const{token:A}=await M.json();if(!A||b)return;v=new EventSource(`${_}${qi}/subscribe?token=${encodeURIComponent(A)}`),v.onmessage=R=>{try{const $=JSON.parse(R.data);$!=null&&$.message&&jl.current($,"success")}catch{}},v.onerror=()=>v==null?void 0:v.close()}catch{}})(),()=>{b=!0,v==null||v.close()}},[mt,L,s,Vl,qi]),!jt)return m.createElement(m.Fragment,null,mS(ft,Lt.length,Dn,C));const Mt=jt,si=Mt.backgroundColor,Ol=si&&Ko(si)!==(Et.colorMode==="dark"?"dark":"light")?Ko(si)==="dark"?ki.text:Mi.text:Et.colors.text,Gi=Mt.height!==void 0?typeof Mt.height=="number"?`${Mt.height}px`:Mt.height:void 0,Yi=Mt.minHeight!==void 0?typeof Mt.minHeight=="number"?`${Mt.minHeight}px`:Mt.minHeight:void 0,Fm=Mt.className?{...zu,display:"flex",flexDirection:"column",width:"100%",maxWidth:"100%",position:"relative",...Gi?{height:Gi}:{},...Yi?{minHeight:Yi}:{},backgroundColor:si||Et.colors.background,color:Ol,...Dt(Mt.className)}:{...zu,display:"flex",flexDirection:"column",position:"relative",width:"100%",maxWidth:"100%",...Gi?{height:Gi}:{},...Yi?{minHeight:Yi}:{},backgroundColor:si||Et.colors.background,color:Ol},Ul=Array.isArray(Mt.components)?Mt.components:[],Bm=fS(we),Hl=(jt==null?void 0:jt.requireAuth)===!0||(Mt==null?void 0:Mt.requiresAuth)===!0||(qe==null?void 0:qe.requiresAuth)===!0||((Kl=qe==null?void 0:qe.config)==null?void 0:Kl.requiresAuth)===!0,Wm=(Hl||Pe)&&!mt?Pm():null,jm=mt&&Hl&&J===!1&&!In?m.createElement("div",{key:"email-banner",style:{position:"fixed",top:0,left:0,right:0,zIndex:9500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 40px",backgroundColor:Et.colorMode==="dark"?"#78350f":"#fef3c7",color:Et.colorMode==="dark"?"#fef3c7":"#92400e",fontSize:"13px",fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},je.renderIcon("alert-triangle",14),m.createElement("span",null,"Verify your email — check your inbox for the confirmation link."),m.createElement("button",{"aria-label":"Dismiss",onClick:()=>Ys(!0),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"inherit",display:"flex",alignItems:"center",padding:"4px"}},je.renderIcon("x",16))):null,vn=e,ql=Array.isArray(vn==null?void 0:vn.widgets)?vn.widgets:[],Gl=new Set,mo=y=>{if(Array.isArray(y))for(const v of y)v&&v.type==="widget"&&v.widgetId&&Gl.add(v.widgetId),v&&Array.isArray(v.children)&&mo(v.children)};mo(Ul);for(const y of ql)mo(y.components);const Vm=ql.filter(y=>Gl.has(y.id)?!1:y.sceneIds==="*"?!0:Array.isArray(y.sceneIds)?y.sceneIds.includes("*")||y.sceneIds.includes(ot):!1);De=[...Ul],(tc=(Zl=vn.layout)==null?void 0:Zl.header)!=null&&tc.length?De.splice(0,0,...vn.layout.header):(nc=(ec=Mt==null?void 0:Mt.layout)==null?void 0:ec.header)!=null&&nc.length&&De.splice(0,0,...Mt.layout.header);for(const y of Vm||[]){const v=y.components||[];if(!v.length)continue;if(y.targetKey){const _=y.targetKey.split("-").filter(Boolean).map(Number);if(_.length>0){let M=De,A=_[0];for(let $=0;$<_.length-1;$++){const N=M[_[$]];if(!N||!Array.isArray(N.children))break;M=N.children,A=_[$+1]}const R=y.targetPosition||"before";if(R==="inside"){const $=M[A];$&&(Array.isArray($.children)||($.children=[]),$.children.unshift(...v))}else R==="after"?M.splice(A+1,0,...v):M.splice(A,0,...v);continue}}const b=y.index??De.length;De.splice(b,0,...v)}(ic=(sc=vn.layout)==null?void 0:sc.footer)!=null&&ic.length?De.push(...vn.layout.footer):(oc=(rc=Mt==null?void 0:Mt.layout)==null?void 0:rc.footer)!=null&&oc.length&&De.push(...Mt.layout.footer);const Om=fo&&fo.size>0?m.createElement("style",{key:"bf-responsive"},Array.from(fo.values()).join(`
|
|
92
|
+
`)):null,Um=m.createElement("style",{key:"bf-transitions"},`#${we} * { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease; }
|
|
93
93
|
@keyframes bf-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
94
94
|
@keyframes bf-fade-out { from { opacity: 1; } to { opacity: 0; } }
|
|
95
95
|
@keyframes bf-slide-in-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
|
|
@@ -110,11 +110,11 @@ ${y.message}`:y.message;jt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.mod
|
|
|
110
110
|
#${we} .bf-loader-spinner { animation: bf-spin 0.7s linear infinite; }
|
|
111
111
|
#${we} .bf-btn-spinner { animation: bf-spin 0.7s linear infinite; }
|
|
112
112
|
@keyframes bf-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
|
113
|
-
@keyframes bf-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }`),
|
|
113
|
+
@keyframes bf-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }`),Hm=De.map((y,v)=>Cr(je,y,v)),qm=Object.values(tn).some(Boolean)||Object.values(us).some(Boolean)?Mt!=null&&Mt.loadingComponent?m.createElement("div",{key:"scene-loader",style:{position:"absolute",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.15)",backdropFilter:"blur(1px)"}},Cr(je,Mt.loadingComponent,0,`${we}-sceneloader`)):m.createElement("div",{key:"scene-loader",style:{position:"absolute",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)"}},m.createElement("div",{className:"bf-loader-spinner",style:{width:"32px",height:"32px",border:"3px solid rgba(128,128,128,0.15)",borderTopColor:"currentColor",borderRadius:"50%"}})):null,Gm=[jm,Wm,k==="modal"&&pS(ft),Fu(zt,Et,je,Mt==null?void 0:Mt.backgroundColor,void 0,void 0,ti),_e&&_e.id!==(zt==null?void 0:zt.id)?Fu(_e,Et,je,Mt==null?void 0:Mt.backgroundColor,je.dismissOverlayModal,10001):null,qm,Pp(e,{sceneId:ot,sceneData:Pt,registry:ce.current,isAuthenticated:mt,colorMode:Et.colorMode,enabled:X,navigateToScene:on,openModal:y=>{const v=Gt[y];v&&se({id:y,definition:v})},submitReport:async y=>{const v=await fetch(new URL("/tenant/diagnostics/ui",Ge()).toString(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:JSON.stringify(y)}),b=await v.json().catch(()=>null);return{submitted:v.ok,status:v.status,body:b,report:y}}})].filter(Boolean),Ym=Et.effects.scrollBehavior||"smooth",Xm=m.createElement("style",{key:"bf-scroll-behavior"},`
|
|
114
114
|
html {
|
|
115
|
-
scroll-behavior: ${
|
|
115
|
+
scroll-behavior: ${Ym};
|
|
116
116
|
}
|
|
117
|
-
`);return m.createElement(m.Fragment,null,E("style",{key:"css-reset"},
|
|
117
|
+
`);return m.createElement(m.Fragment,null,E("style",{key:"css-reset"},Bm),Xm,Om,Um,m.createElement("div",{id:we,style:Fm,ref:gt},...Hm,...Gm))}function yS(e){return m.createElement(gS,e)}function bS(e,t,n={}){var f,p;const s=JSON.stringify(e),r=(n.colorMode||"dark")==="dark",o=n.primaryColor||(r?"#8b5cf6":"#7c3aed"),l=r?"#111827":"#f9fafb",c=r?"#1f2937":"#ffffff",h=r?"#374151":"#e5e7eb",a=((p=(f=e.config)==null?void 0:f.effects)==null?void 0:p.scrollBehavior)||"smooth",u=n.sdkEndpoint?`
|
|
118
118
|
<script src="https://unpkg.com/@backflow.sdk/client@latest/dist/backflow.umd.js"><\/script>
|
|
119
119
|
<script>
|
|
120
120
|
(function() {
|
|
@@ -184,4 +184,4 @@ ${y.message}`:y.message;jt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.mod
|
|
|
184
184
|
root.render(React.createElement(WorkflowApp));
|
|
185
185
|
<\/script>
|
|
186
186
|
</body>
|
|
187
|
-
</html>`}exports.BREAKPOINTS_LIST=
|
|
187
|
+
</html>`}exports.BREAKPOINTS_LIST=Rf;exports.BREAKPOINT_MIN_WIDTHS=Af;exports.DARK_COLORS=ki;exports.LIGHT_COLORS=Mi;exports.UnifiedWorkflowRenderer=yS;exports.buildRouteMaps=gm;exports.buildSDKCall=lS;exports.clearMonitorLog=$a;exports.connectRemoteControl=Xu;exports.disconnectRemoteControl=Jo;exports.executeSDKCall=Mr;exports.extractSDKCall=pi;exports.fillElement=Pa;exports.findElement=Tn;exports.findElements=Wr;exports.generateComponentCSS=ym;exports.generateStandaloneHTML=bS;exports.getFeatherIcon=wp;exports.getMonitorLog=_a;exports.getSceneFromHash=Ta;exports.hasAnyResponsive=ya;exports.initBackflowAgent=Qu;exports.isAgentEnabled=Vu;exports.isSDKCall=Ci;exports.parseAlignItemsResponsive=If;exports.parseAllResponsiveClasses=ba;exports.parseBorderRadiusResponsive=Lf;exports.parseClassName=Tl;exports.parseClassNameFull=Tl;exports.parseDisplayResponsive=ml;exports.parseFlexDirectionResponsive=Pf;exports.parseGapResponsive=_f;exports.parseGridColsResponsive=pl;exports.parseJustifyResponsive=Df;exports.parseMarginResponsive=Nf;exports.parsePaddingResponsive=yl;exports.parseTextSizeResponsive=gl;exports.parseWidthResponsive=$f;exports.renderIcon=Na;exports.resolveConfig=Ju;exports.setAgentEnabled=ju;exports.setHashForScene=kr;exports.startMonitoring=Yu;exports.triggerElement=Ou;exports.useContainerWidth=zf;
|